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