Skip to content

Commit 938e20b

Browse files
committed
complete zsh config
1 parent 70c1b64 commit 938e20b

12 files changed

Lines changed: 150 additions & 0 deletions

zsh.d/10defaults.zsh.tmpl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/zsh
2+
3+
# Basic prompt of user@host:/path%
4+
#
5+
# Same format as scp/rsync path and can be copied and used as such
6+
PROMPT='%n@%m:%~%# '
7+
8+
# Default text editor.
9+
EDITOR="nano"
10+
VISUAL="nano"
11+
12+
# Default pager to read text files
13+
PAGER="less"
14+
15+
export EDITOR VISUAL PAGER
16+
17+
# Explicitly set zsh to emacs mode. Otherwise it will guess based on
18+
# value of $EDITOR
19+
command -v bindkey > /dev/null 2>&1 && bindkey -e
20+
21+
# GitHub API token for homebrew. Lifts API rate limits that can plague
22+
# frequent 'brew' usage.
23+
#
24+
# WARNING: when creating token, unselect *all* scopes
25+
# See:
26+
# man brew
27+
# https://github.com/settings/tokens
28+
# https://developer.github.com/v3/#rate-limiting
29+
#export HOMEBREW_GITHUB_API_TOKEN=""
30+

zsh.d/15wintitle.zsh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/zsh
2+
3+
case "${TERM}" in
4+
xterm*)
5+
# $'\e]0;...\a' # set xterm window and icon (tab) name
6+
# $'\e]1;...\a' # set xterm icon (tab) name
7+
# $'\e]2;...\a' # set xterm window name
8+
# $'\e]6;...\a' # working document as file://host/path/file *
9+
# $'\e]7;...\a' # working directory as file://host/path/dir/ *
10+
# * url-encoded
11+
precmd() { print -Pn $'%{\e]2;%n %~\a%}'; }
12+
;;
13+
screen*|tmux*)
14+
# $'\ePtmux;...\a\e\\' # pass control sequence to xterm
15+
# $'\ek...\e\\' # set tmux window name
16+
precmd() { print -Pn $'\ePtmux;\e\e]2;%n %~\a\e\\' $'%{\ek%n %~\e\\%}'; }
17+
;;
18+
esac

zsh.d/40zsh.zsh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/zsh
2+
3+
# Don't put duplicate lines in the history. See zshoptions(1) for more options
4+
setopt histignorealldups
5+
6+
# Append to the history file, don't overwrite it
7+
setopt appendhistory
8+
setopt incappendhistory
9+
10+
# Share history between terminals
11+
setopt sharehistory
12+
13+
typeset -U PATH path
14+
15+
# Set the number of commands zsh should remember
16+
HISTSIZE=1000
17+
SAVEHIST=1000

zsh.d/50completions.zsh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/zsh
2+
3+
if [[ -n "${HOMEBREW_PREFIX:-}" ]]; then
4+
fpath=("${HOMEBREW_PREFIX}/share/zsh/site-functions" $fpath)
5+
6+
autoload -Uz compinit
7+
compinit
8+
fi

zsh.d/50composer.zsh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/zsh
2+
3+
for dir in "${HOME}/.composer/vendor/bin" "${HOME}/.local/composer/vendor/bin"; do
4+
[[ -d "${dir}" ]] && path=("${dir}" $path)
5+
done

zsh.d/50golang.zsh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/zsh
2+
3+
# Find GOROOT, preferring homebrew's go installation over golang.org's
4+
# install pkg
5+
for dir in "${HOMEBREW_PREFIX:-/usr/local}/opt/go/libexec" /usr/local/go; do
6+
if [[ -d "${dir}" ]]; then
7+
export GOROOT="${dir}"
8+
break
9+
fi
10+
done
11+
12+
# Add commom-ish source directories to GOPATH
13+
if [[ -n "${GOROOT:-}" ]]; then
14+
typeset -U -T GOPATH gopath
15+
for dir in "${HOME}/go" "${HOME}/src"; do
16+
gopath+=("${dir}")
17+
path=("${dir}/bin" $path)
18+
done
19+
20+
export GOPATH PATH
21+
fi

zsh.d/50less.zsh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/zsh
2+
3+
# Use lesspipe, if available, to support more formats and syntax
4+
# highlighting
5+
for lesspipe in lesspipe lesspipe.sh; do
6+
if command -v "${lesspipe}" > /dev/null; then
7+
eval "$(SHELL=/bin/zsh "${lesspipe}")"
8+
break
9+
fi
10+
done
11+
12+
# Defaults for less
13+
# -i ignore case (when search term is lowercase
14+
# -M verbose prompt
15+
# -R show raw control characters (ANSI colors)
16+
LESS="-iMR"
17+
18+
# Disable less's history file
19+
LESSHISTFILE=-
20+
21+
export LESS LESSHISTFILE

zsh.d/50python.zsh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/zsh
2+
3+
# Add python's user bin directory to PATH
4+
if command -v python3 >/dev/null; then
5+
path=("$(python3 -m site --user-base)/bin" $path)
6+
fi
7+
8+
export PATH

zsh.d/50ruby.zsh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/zsh
2+
3+
# add ruby's user gems bin directory to PATH
4+
if command -v ruby > /dev/null; then
5+
ruby_dir="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin"
6+
[[ -d "${ruby_dir}" ]] && path=("${ruby_dir}" $path)
7+
fi
8+
unset ruby_dir

zsh.d/60userbin.zsh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/zsh
2+
3+
# Add common user bin directories to PATH
4+
path=( "${HOME}/bin" "$HOME/.local/bin" $path )

0 commit comments

Comments
 (0)