]> git.sev.monster Git - dotfiles.git/blame - base/.zshrc
actually set PINENTRY_USER_DATA, fix invocation
[dotfiles.git] / base / .zshrc
CommitLineData
b3de8395 1### imports
2source ~/bin/.check-busybox
3
ba63cd01 4### options
a8f1ccaf 5setopt NO_BEEP NO_CLOBBER
6## cd
7setopt AUTO_CD CDABLE_VARS
8## completion
9setopt GLOB_COMPLETE
10## line
11setopt EXTENDED_GLOB GLOB_DOTS MARK_DIRS NOMATCH NUMERIC_GLOB_SORT
12## prompt
13setopt PROMPT_SUBST
14## jobs
15setopt AUTO_CONTINUE
16## history
17setopt NO_HIST_SAVE_BY_COPY HIST_IGNORE_DUPS SHARE_HISTORY
7045a58b 18
ba63cd01 19### keys
7045a58b 20bindkey -v
b3d0247b 21KEYTIMEOUT=1
ba63cd01 22## xorg
7045a58b 23bindkey "^[[7~" beginning-of-line #Home
24bindkey -a "^[[7~" beginning-of-line
25bindkey "^[[8~" end-of-line #End
26bindkey -a "^[[8~" end-of-line
27bindkey "^[[3~" delete-char #Del
28bindkey -a "^[[3~" delete-char
ba63cd01 29## history search
1f53b630 30autoload -Uz up-line-or-beginning-search down-line-or-beginning-search && {
d3712462 31 if [[ -n "$key[Up]" ]] {
1f53b630 32 zle -N up-line-or-beginning-search
33 bindkey -- "$key[Up]" up-line-or-beginning-search
34 }
35 if [[ -n "$key[Down]" ]] {
36 bindkey -- "$key[Down]" down-line-or-beginning-search
37 zle -N down-line-or-beginning-search
38 }
39}
7045a58b 40
ba63cd01 41### aliases
189288f7 42alias h="history -25"
43alias j="jobs -l"
b3d0247b 44alias l="ls -AF"
1f53b630 45alias e="${EDITOR:-vi}" # TODO: make sure vi is there or use safe default
a568f7fa 46if [[ "$OSTYPE" =~ '^(free|net)bsd' ]] {
47 alias ll="ls -lAFho"
48} else {
49 alias ll="ls -lAFh"
50}
55a16ad2 51alias se=sudoedit
ba63cd01 52## ps
1f53b630 53local p=
d3712462 54if which pstree >/dev/null 2>&1 && ! check-busybox pstree; then
1f53b630 55 # use pstree, but NOT busybox pstree because it kinda sucks
a568f7fa 56 p="pstree -wg3"
d3712462 57elif [[ "$OSTYPE" =~ '^freebsd' ]]; then
a568f7fa 58 p="ps -aSdfxwwouser=USR -ogroup=GRP -opid,nice=NI \
59 -o%cpu,%mem,tty,stat,start=START -oetime,command"
d3712462 60elif check-busybox ps; then
a568f7fa 61 # busybox compatible
62 p="ps -eouser='USR ' -ogroup='GRP ' \
63 -opid=' PID' -onice=' NI' -ovsz=' MEM' \
64 -otty,stat,etime,comm"
d3712462 65else
a568f7fa 66 # XXX: untested, posix
67 # TODO: support gnu ps
68 p="ps -eouser=USR -ogroup=GRP -opid,nice=NI \
69 -opcpu=CPU -ovsz=MEM -otty,stat,etime,comm"
d3712462 70fi
71if [[ "$(basename "$PAGER")" = "less" ]] {
72 p="$p | less -SE"
73} else {
74 p="$p | \"${PAGER:-more}\""
a568f7fa 75}
b3d0247b 76alias pa="$p"
77alias spa="sudo $p"
78unset p
ba63cd01 79## py venv
ce090b98 80alias va="source bin/activate"
d7ea63a2 81alias vd="deactivate"
ba63cd01 82## be paranoid
189288f7 83alias cp='cp -ip'
84alias mv='mv -i'
f7960c69 85if [[ "$OSTYPE" =~ '^freebsd' ]] {
ba63cd01 86 # don't confirm if only a few files are deleted
87 alias rm='rm -I'
88} else {
1f53b630 89 # TODO: similar behavior for non-freebsd, or impliment in zsh
ba63cd01 90 alias rm='rm -i'
9fddba79 91}
1f53b630 92## go up directories
93function up() {
94 cd $(printf '../%.0s' {1..${1:-1}})
b3d0247b 95}
ff1edfa8 96
ba63cd01 97### hooks
f7960c69 98local _exectime=
b3d0247b 99function precmd {
8f9c4a17 100 # change terminal title
1f53b630 101 # TODO: update and send BEL when job status changes
ba63cd01 102 print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\"
8f9c4a17 103 # bell if exec takes 5s
104 if ((SECONDS - _exectime >= 5)) print "\a"
1f53b630 105 # we could update vcs_info here, but let prompt take care of it
106 # if it doesn't use vcs, it can be ignored safely
b3d0247b 107}
108function preexec {
8f9c4a17 109 # change terminal title to show command
ba63cd01 110 print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1"
8f9c4a17 111 # save last exec time for bell
a568f7fa 112 # XXX: does not run for blank cmdline
b3d0247b 113 _exectime=$SECONDS
114}
8f9c4a17 115function chpwd {
a568f7fa 116 # echo dir on cwd change
8f9c4a17 117 l
118}
b3d0247b 119
f7960c69 120### system-specific configs and aliases
121case "$OSTYPE"; in
122 freebsd*)
123 ## vt binds
124 bindkey "^[[H" beginning-of-line #Home
125 bindkey -a "^[[H" beginning-of-line
126 bindkey "^[[F" end-of-line #End
127 bindkey -a "^[[F" end-of-line
ba63cd01 128
81c3957e 129 # colors
130 export CLICOLOR=
131 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'
132
f7960c69 133 ## sound
134 function s { sysctl hw.snd.default_unit${1:+\=$1} }
135 alias vol mixer
ba63cd01 136
f7960c69 137 ## install port dependencies from pkg (like pkgsrc `bmake bin-install')
138 #XXX: should probably use package-depends where possible, breaks when
139 # port name is different to package name
140 # (eg. graphics/sdl20 == sdl2, devel/glib20 == glib2, etc)
141 function portpkg {
142 case "$1" {
143 build|run)
144 sudo pkg install -AU $(make ${1}-depends-list |
145 sed 's_/usr/ports/_ _' | tr -d '\n')
146 ;;
147 *) echo "Usage: \`portpkg <build|run>' in a port directory"
148 return 1;;
149 }
150 };;
151 netbsd)
152 ## sound
153 function s {
154 if [[ -z "$1" ]] {
155 ll /dev/mixer /dev/sound /dev/audio
156 return
157 }
158 for x in mixer sound audio; do
159 ln -sf /dev/$x"$1" /dev/$x
160 done
ba63cd01 161 }
f7960c69 162 function vol {
163 if [[ -z "$1" ]] {
164 for x in $(mixerctl -a | grep 'outputs\.master'); do
165 echo $x
166 done
167 return
168 }
169 mixerctl -w outputs.master"$2"="$1"
170 };;
a568f7fa 171 *)
172 ## sound
173 # TODO: test alsa/oss/sndio/portaudio/pulse in order of importance
1f53b630 174 function s() {}
b3de8395 175 function vol() {}
f7960c69 176esac
ba63cd01 177
1f53b630 178### modules & styles
179## vcs
1f53b630 180zstyle ':vcs_info:*' enable git
181#zstyle ':vcs_info:git*' check-for-changes true #too slow
182zstyle ':vcs_info:git*:dotfiles' check-for-changes true
183zstyle ':vcs_info:git*' check-for-staged-changes true
30cffb95 184autoload -Uz vcs_info
1f53b630 185
186## compinit
1f53b630 187zstyle ':completion:*' auto-description '[arg] %d'
189288f7 188zstyle ':completion:*' expand suffix
189zstyle ':completion:*' format '# %d'
190zstyle ':completion:*' group-name ''
191zstyle ':completion:*' ignore-parents parent
192zstyle ':completion:*' insert-unambiguous false
193zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
194zstyle ':completion:*' list-prompt '%B%i%b'
195zstyle ':completion:*' list-suffixes true
196zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
197zstyle ':completion:*' menu select=1
198zstyle ':completion:*' original false
199zstyle ':completion:*' select-prompt '%B%l%b'
200zstyle ':completion:*' verbose true
81c3957e 201autoload -Uz compinit && compinit
189288f7 202
1f53b630 203## prompt
81c3957e 204# do this last so prompt can potentially override other settings
1f53b630 205autoload -Uz promptinit && promptinit
d3712462 206prompt arrows
1f53b630 207
81c3957e 208### load site-specific
209if [[ -f ~/.zshrc.local ]] { source ~/.zshrc.local }
b3de8395 210
211### unset imports
212unfunction check-busybox
213
1f53b630 214# vim: set et sts=4 sw=4 ts=8 tw=79 :
This page took 0.072553 seconds and 4 git commands to generate.