2 setopt NO_BEEP NO_CLOBBER
4 setopt AUTO_CD CDABLE_VARS
8 setopt EXTENDED_GLOB GLOB_DOTS MARK_DIRS NOMATCH NUMERIC_GLOB_SORT
14 setopt NO_HIST_SAVE_BY_COPY HIST_IGNORE_DUPS SHARE_HISTORY
17 # TODO: investigate "^[[200~" bracketed-paste
21 if (( $#terminfo == 0 )) {
22 # terminfo is not set or empty
23 function find_keymap {
24 for f in ${ZDOTDIR:-$HOME}/.zkbd/${TERM}{-${DISPLAY:-${VENDOR}-${OSTYPE}},}
25 [[ -f $f ]] && keymap=$f && break
29 if read -q "?Can't read terminfo. Add new zkbd keymap? [y/N]"; then
31 autoload -Uz zkbd && zkbd
40 echo "Failed to source file $keymap" >&2
42 unfunction find_keymap; unset keymap
44 # activate application mode for zle so terminfo keys work
45 # don't do this for zkbd since application mode shouldn't have ben enabled
46 if [[ -v terminfo[smkx] && -v terminfo[rmkx] ]] {
47 autoload -Uz add-zle-hook-widget
48 function _enter-application-mode { echoti smkx }
49 add-zle-hook-widget line-init _enter-application-mode
50 function _exit-application-mode { echoti rmkx }
51 add-zle-hook-widget line-finish _exit-application-mode
52 trap _exit-application-mode EXIT
54 # match zkbd hash as best we can to terminfo
56 key[F1]=$terminfo[kf1]
57 key[F2]=$terminfo[kf2]
58 key[F3]=$terminfo[kf3]
59 key[F4]=$terminfo[kf4]
60 key[F5]=$terminfo[kf5]
61 key[F6]=$terminfo[kf6]
62 key[F7]=$terminfo[kf7]
63 key[F8]=$terminfo[kf8]
64 key[F9]=$terminfo[kf9]
65 key[F10]=$terminfo[kf10]
66 key[F11]=$terminfo[kf11]
67 key[F12]=$terminfo[kf12]
68 key[Backspace]=$terminfo[kbs]
69 key[Insert]=$terminfo[kich1]
70 key[Home]=$terminfo[khome]
71 key[PageUp]=$terminfo[kpp]
72 key[Delete]=$terminfo[kdch1]
73 key[End]=$terminfo[kend]
74 key[PageDown]=$terminfo[knp]
75 key[Up]=$terminfo[kcuu1]
76 key[Down]=$terminfo[kcud1]
77 key[Left]=$terminfo[kcub1]
78 key[Right]=$terminfo[kcuf1]
79 #key[Menu]=$terminfo[] #TODO: not in termcap?
82 ## bind keys in both viins and vicmd modes
88 # - will use same command as viins
89 bindkey -a -- $k ${3:/-/$2}
93 multibind Backspace backward-delete-char vi-backward-char
94 multibind Insert overwrite-mode vi-insert
95 multibind Home beginning-of-line -
96 multibind PageUp up-line-or-history -
97 multibind Delete delete-char vi-delete-char
98 multibind End end-of-line -
99 multibind PageDown down-line-or-history -
100 multibind Left backward-char vi-backward-char
101 multibind Right forward-char vi-forward-char
103 autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
104 zle -N up-line-or-beginning-search
105 multibind Up up-line-or-beginning-search -
106 zle -N down-line-or-beginning-search
107 multibind Down down-line-or-beginning-search -
111 ## generic abbreviations
112 alias h="history -25"
115 alias p="${PAGER:-more}" # TODO: make sure more is there or use safe default
116 alias e="${EDITOR:-vi}" # TODO: make sure vi is there or use safe default
117 if [[ "$OSTYPE" =~ '^(free|net)bsd' ]] {
126 if [[ "$OSTYPE" =~ '^freebsd' ]] {
127 # don't confirm if only a few files are deleted
130 # TODO: similar behavior for non-freebsd, or impliment in zsh
135 cd $(printf '../%.0s' {1..${1:-1}})
138 alias va="source bin/activate"
139 alias vd="deactivate"
141 # source helper function
142 source ~/bin/.check-busybox
143 if which pstree >/dev/null 2>&1 && ! check-busybox pstree; then
144 # use pstree, but NOT busybox pstree because it kinda sucks
146 elif [[ "$OSTYPE" =~ '^freebsd' ]]; then
147 ps="ps -aSdfxwwouser=USR -ogroup=GRP -opid,nice=NI \
148 -o%cpu,%mem,tty,stat,start=START -oetime,command"
149 elif check-busybox ps; then
151 ps="ps -eouser='USR ' -ogroup='GRP ' \
152 -opid=' PID' -onice=' NI' -ovsz=' MEM' \
153 -otty,stat,etime,comm"
155 # XXX: untested, posix
156 # TODO: support gnu ps
157 ps="ps -eouser=USR -ogroup=GRP -opid,nice=NI \
158 -opcpu=CPU -ovsz=MEM -otty,stat,etime,comm"
160 unfunction check-busybox
161 if [[ "$(basename "$PAGER")" = "less" ]] {
164 ps="$ps | \"${PAGER:-more}\""
171 autoload -Uz add-zsh-hook
173 function sev_preexec {
174 # change terminal title to show command
175 print -n "\e]2;$(print -P '%#')${SSH_CLIENT+$USER@$HOST:}$1\e\\"
176 # save last exec time for bell
177 # XXX: does not run for blank cmdline
178 _sev_exectime=$SECONDS
180 add-zsh-hook preexec sev_preexec
181 function sev_precmd {
182 # change terminal title
183 # TODO: update and send BEL when job status changes
184 print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\"
185 # bell if exec takes 5s
186 if (( SECONDS - _sev_exectime >= 5 )) print "\a"
187 # we could update vcs_info here, but let prompt take care of it
188 # if it doesn't use vcs, it can be ignored safely
190 add-zsh-hook precmd sev_precmd
192 # echo dir on cwd change
195 add-zsh-hook chpwd sev_chpwd
197 ### system-specific configs and aliases
202 export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
205 function s { sysctl hw.snd.default_unit${1:+\=$1} }
208 ## install port dependencies from pkg (like pkgsrc `bmake bin-install')
209 # XXX: should probably use package-depends where possible, breaks when
210 # port name is different to package name
211 # (eg. graphics/sdl20 == sdl2, devel/glib20 == glib2, etc)
215 sudo pkg install -AU $(make ${1}-depends-list |
216 sed 's_/usr/ports/_ _' | tr -d '\n')
218 *) echo "Usage: \`portpkg <build|run>' in a port directory"
226 ll /dev/mixer /dev/sound /dev/audio
229 for x in mixer sound audio; do
230 ln -sf /dev/$x"$1" /dev/$x
235 for x in $(mixerctl -a | grep 'outputs\.master'); do
240 mixerctl -w outputs.master"$2"="$1"
244 # TODO: test alsa/oss/sndio/portaudio/pulse in order of importance
251 zstyle ':vcs_info:*' enable git
252 #zstyle ':vcs_info:git*' check-for-changes true #too slow
253 zstyle ':vcs_info:git*:dotfiles' check-for-changes true
254 zstyle ':vcs_info:git*' check-for-staged-changes true
255 autoload -Uz vcs_info
258 zstyle ':completion:*' auto-description '[arg] %d'
259 zstyle ':completion:*' expand suffix
260 zstyle ':completion:*' format '# %d'
261 zstyle ':completion:*' group-name ''
262 zstyle ':completion:*' ignore-parents parent
263 zstyle ':completion:*' insert-unambiguous false
264 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
265 zstyle ':completion:*' list-prompt '%B%i%b'
266 zstyle ':completion:*' list-suffixes true
267 zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
268 zstyle ':completion:*' menu select=1
269 zstyle ':completion:*' original false
270 zstyle ':completion:*' select-prompt '%B%l%b'
271 zstyle ':completion:*' verbose true
272 autoload -Uz compinit && compinit
275 autoload -Uz promptinit && promptinit
278 ### load site-specific
279 if [[ -f ~/.zshrc.local ]] { source ~/.zshrc.local }
281 # vim: set et sts=4 sw=4 ts=8 tw=79 :