]>
Commit | Line | Data |
---|---|---|
1f53b630 | 1 | ### user-local fpath |
2 | fpath=(~/.zsh ~/.zsh/functions/Prompts "${fpath[@]}") | |
3 | ||
ba63cd01 | 4 | ### options |
a8f1ccaf | 5 | setopt NO_BEEP NO_CLOBBER |
6 | ## cd | |
7 | setopt AUTO_CD CDABLE_VARS | |
8 | ## completion | |
9 | setopt GLOB_COMPLETE | |
10 | ## line | |
11 | setopt EXTENDED_GLOB GLOB_DOTS MARK_DIRS NOMATCH NUMERIC_GLOB_SORT | |
12 | ## prompt | |
13 | setopt PROMPT_SUBST | |
14 | ## jobs | |
15 | setopt AUTO_CONTINUE | |
16 | ## history | |
17 | setopt NO_HIST_SAVE_BY_COPY HIST_IGNORE_DUPS SHARE_HISTORY | |
7045a58b | 18 | HISTFILE=~/.histfile |
a8f1ccaf | 19 | HISTSIZE=1000 |
20 | SAVEHIST=1000 | |
7045a58b | 21 | |
ba63cd01 | 22 | ### keys |
7045a58b | 23 | bindkey -v |
b3d0247b | 24 | KEYTIMEOUT=1 |
ba63cd01 | 25 | ## xorg |
7045a58b | 26 | bindkey "^[[7~" beginning-of-line #Home |
27 | bindkey -a "^[[7~" beginning-of-line | |
28 | bindkey "^[[8~" end-of-line #End | |
29 | bindkey -a "^[[8~" end-of-line | |
30 | bindkey "^[[3~" delete-char #Del | |
31 | bindkey -a "^[[3~" delete-char | |
ba63cd01 | 32 | ## history search |
1f53b630 | 33 | autoload -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 | } | |
7045a58b | 43 | |
ba63cd01 | 44 | ### aliases |
189288f7 | 45 | alias h="history -25" |
46 | alias j="jobs -l" | |
b3d0247b | 47 | alias l="ls -AF" |
1f53b630 | 48 | alias e="${EDITOR:-vi}" # TODO: make sure vi is there or use safe default |
a568f7fa | 49 | if [[ "$OSTYPE" =~ '^(free|net)bsd' ]] { |
50 | alias ll="ls -lAFho" | |
51 | } else { | |
52 | alias ll="ls -lAFh" | |
53 | } | |
ba63cd01 | 54 | ## ps |
1f53b630 | 55 | local p= |
56 | if { which pstree >/dev/null 2>&1 && \ | |
57 | [[ ! "$(readlink -f $(which pstree))" =~ "/busybox" ]] } { | |
58 | # use pstree, but NOT busybox pstree because it kinda sucks | |
a568f7fa | 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 | } | |
74 | p="$p | ${PAGER:-more} -Se" | |
b3d0247b | 75 | alias pa="$p" |
76 | alias spa="sudo $p" | |
77 | unset p | |
ba63cd01 | 78 | ## py venv |
ce090b98 | 79 | alias va="source bin/activate" |
d7ea63a2 | 80 | alias vd="deactivate" |
ba63cd01 | 81 | ## be paranoid |
189288f7 | 82 | alias cp='cp -ip' |
83 | alias mv='mv -i' | |
f7960c69 | 84 | if [[ "$OSTYPE" =~ '^freebsd' ]] { |
ba63cd01 | 85 | # don't confirm if only a few files are deleted |
86 | alias rm='rm -I' | |
87 | } else { | |
1f53b630 | 88 | # TODO: similar behavior for non-freebsd, or impliment in zsh |
ba63cd01 | 89 | alias rm='rm -i' |
9fddba79 | 90 | } |
1f53b630 | 91 | ## go up directories |
92 | function up() { | |
93 | cd $(printf '../%.0s' {1..${1:-1}}) | |
b3d0247b | 94 | } |
ff1edfa8 | 95 | |
ba63cd01 | 96 | ### hooks |
f7960c69 | 97 | local _exectime= |
b3d0247b | 98 | function precmd { |
8f9c4a17 | 99 | # change terminal title |
1f53b630 | 100 | # TODO: update and send BEL when job status changes |
ba63cd01 | 101 | print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\" |
8f9c4a17 | 102 | # bell if exec takes 5s |
103 | if ((SECONDS - _exectime >= 5)) print "\a" | |
1f53b630 | 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 | |
b3d0247b | 106 | } |
107 | function preexec { | |
8f9c4a17 | 108 | # change terminal title to show command |
ba63cd01 | 109 | print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1" |
8f9c4a17 | 110 | # save last exec time for bell |
a568f7fa | 111 | # XXX: does not run for blank cmdline |
b3d0247b | 112 | _exectime=$SECONDS |
113 | } | |
8f9c4a17 | 114 | function chpwd { |
a568f7fa | 115 | # echo dir on cwd change |
8f9c4a17 | 116 | l |
117 | } | |
b3d0247b | 118 | |
f7960c69 | 119 | ### system-specific configs and aliases |
120 | case "$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 | |
ba63cd01 | 127 | |
f7960c69 | 128 | ## sound |
129 | function s { sysctl hw.snd.default_unit${1:+\=$1} } | |
130 | alias vol mixer | |
ba63cd01 | 131 | |
f7960c69 | 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 | |
ba63cd01 | 156 | } |
f7960c69 | 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 | };; | |
a568f7fa | 166 | *) |
167 | ## sound | |
168 | # TODO: test alsa/oss/sndio/portaudio/pulse in order of importance | |
1f53b630 | 169 | function s() {} |
f7960c69 | 170 | esac |
ba63cd01 | 171 | |
1f53b630 | 172 | ### modules & styles |
173 | ## vcs | |
174 | autoload -Uz vcs_info | |
175 | zstyle ':vcs_info:*' enable git | |
176 | #zstyle ':vcs_info:git*' check-for-changes true #too slow | |
177 | zstyle ':vcs_info:git*:dotfiles' check-for-changes true | |
178 | zstyle ':vcs_info:git*' check-for-staged-changes true | |
179 | ||
180 | ## compinit | |
189288f7 | 181 | # The following lines were added by compinstall |
1f53b630 | 182 | zstyle ':completion:*' auto-description '[arg] %d' |
189288f7 | 183 | zstyle ':completion:*' expand suffix |
184 | zstyle ':completion:*' format '# %d' | |
185 | zstyle ':completion:*' group-name '' | |
186 | zstyle ':completion:*' ignore-parents parent | |
187 | zstyle ':completion:*' insert-unambiguous false | |
188 | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
189 | zstyle ':completion:*' list-prompt '%B%i%b' | |
190 | zstyle ':completion:*' list-suffixes true | |
191 | zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' | |
192 | zstyle ':completion:*' menu select=1 | |
193 | zstyle ':completion:*' original false | |
194 | zstyle ':completion:*' select-prompt '%B%l%b' | |
195 | zstyle ':completion:*' verbose true | |
196 | zstyle :compinstall filename '/home/ds6/.zshrc' | |
197 | ||
198 | autoload -Uz compinit | |
199 | compinit | |
200 | # End of lines added by compinstall | |
201 | ||
1f53b630 | 202 | ## prompt |
203 | # do this last so prompt can potentially override | |
204 | autoload -Uz promptinit && promptinit | |
205 | prompt ds6 | |
206 | ||
207 | # vim: set et sts=4 sw=4 ts=8 tw=79 : |