]>
Commit | Line | Data |
---|---|---|
d877aef2 | 1 | ### options |
12f46d4e | 2 | setopt autocd extendedglob |
3 | unsetopt beep | |
4 | ||
d877aef2 | 5 | ### history |
12f46d4e | 6 | setopt appendhistory |
7 | HISTFILE=~/.histfile | |
8 | HISTSIZE=100 | |
9 | SAVEHIST=100 | |
10 | ||
d877aef2 | 11 | ### keys |
12f46d4e | 12 | bindkey -v |
e8abe786 | 13 | KEYTIMEOUT=1 |
d877aef2 | 14 | ## xorg |
12f46d4e | 15 | bindkey "^[[7~" beginning-of-line #Home |
16 | bindkey -a "^[[7~" beginning-of-line | |
17 | bindkey "^[[8~" end-of-line #End | |
18 | bindkey -a "^[[8~" end-of-line | |
19 | bindkey "^[[3~" delete-char #Del | |
20 | bindkey -a "^[[3~" delete-char | |
d877aef2 | 21 | ## history search |
12f46d4e | 22 | autoload -Uz up-line-or-beginning-search down-line-or-beginning-search |
23 | zle -N up-line-or-beginning-search | |
24 | zle -N down-line-or-beginning-search | |
25 | [[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search | |
26 | [[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search | |
27 | ||
d877aef2 | 28 | ### aliases |
1b8a4102 | 29 | alias h="history -25" |
30 | alias j="jobs -l" | |
e8abe786 | 31 | alias l="ls -AF" |
dcac60d9 | 32 | if [[ "$OSTYPE" =~ '^(free|net)bsd' ]] { |
33 | alias ll="ls -lAFho" | |
34 | } else { | |
35 | alias ll="ls -lAFh" | |
36 | } | |
d877aef2 | 37 | ## ps |
dcac60d9 | 38 | local p="" |
39 | if { which pstree >/dev/null 2>&1 && [[ ! "$(readlink -f $(which pstree))" =~ "/busybox" ]] } { | |
40 | p="pstree -wg3" | |
41 | } elif [[ "$OSTYPE" =~ '^freebsd' ]] { | |
42 | p="ps -aSdfxwwouser=USR -ogroup=GRP -opid,nice=NI \ | |
43 | -o%cpu,%mem,tty,stat,start=START -oetime,command" | |
44 | } elif [[ "$(readlink -f $(which ps))" =~ "/busybox" ]] { | |
45 | # busybox compatible | |
46 | p="ps -eouser='USR ' -ogroup='GRP ' \ | |
47 | -opid=' PID' -onice=' NI' -ovsz=' MEM' \ | |
48 | -otty,stat,etime,comm" | |
49 | } else { | |
50 | # XXX: untested, posix | |
51 | # TODO: support gnu ps | |
52 | p="ps -eouser=USR -ogroup=GRP -opid,nice=NI \ | |
53 | -opcpu=CPU -ovsz=MEM -otty,stat,etime,comm" | |
54 | } | |
55 | p="$p | ${PAGER:-more} -Se" | |
e8abe786 | 56 | alias pa="$p" |
57 | alias spa="sudo $p" | |
58 | unset p | |
d877aef2 | 59 | ## py venv |
3edfaacd | 60 | alias va="source bin/activate" |
ab4fdc87 | 61 | alias vd="deactivate" |
d877aef2 | 62 | ## be paranoid |
1b8a4102 | 63 | alias cp='cp -ip' |
64 | alias mv='mv -i' | |
ff1a2414 | 65 | if [[ "$OSTYPE" =~ '^freebsd' ]] { |
d877aef2 | 66 | # don't confirm if only a few files are deleted |
67 | alias rm='rm -I' | |
68 | } else { | |
dcac60d9 | 69 | # TODO: similar behavior for non-freebsd |
d877aef2 | 70 | alias rm='rm -i' |
118fb6e0 | 71 | } |
1b8a4102 | 72 | |
d877aef2 | 73 | ### prompt |
e8abe786 | 74 | setopt prompt_subst |
dcac60d9 | 75 | # DEPR: color reset added to NetBSD in PR/53245, following is not needed for recent releases |
76 | #local f= | |
d1802b02 | 77 | #XXX: can't think of a way to tell if ssh client is on wscons, just kludge 24/7 |
78 | #if [[ "$OSTYPE" = "netbsd" && ( "$TERM" =~ "^wsvt" || "$TERM" =~ '^vt' ) ]] { | |
79 | # # fix for wscons | |
80 | # f="%F{white}" | |
81 | #} else { | |
dcac60d9 | 82 | # f="%f" |
d1802b02 | 83 | #} |
dcac60d9 | 84 | PROMPT='%F{$VICOL}%n%f@%F{$VICOL}%2m%f%(?../%F{red}$?%f)%# ' |
85 | RPROMPT='%F{yellow}${vcs_info_msg_0_:-%~}%f %T' | |
e8abe786 | 86 | |
d877aef2 | 87 | ## change color based on zle vi mode |
e8abe786 | 88 | function zle-line-init zle-keymap-select { |
89 | VICOL="${${KEYMAP:/vicmd/red}:/(main|viins)/green}" | |
90 | zle reset-prompt | |
91 | } | |
92 | zle -N zle-line-init | |
93 | zle -N zle-keymap-select | |
94 | ||
d877aef2 | 95 | ## vcs |
e8abe786 | 96 | autoload -Uz vcs_info |
97 | zstyle ':vcs_info:*' enable git | |
dcac60d9 | 98 | zstyle ':vcs_info:git*' formats '%c%u%%F{green}%r/%b%%F{white}/%%F{yellow}%S%%f' |
99 | zstyle ':vcs_info:git*' actionformats '%%F{red}(%a)%f %c%u%%F{green}%r/%b%f/%%F{yellow}%S%f' | |
a6e5a638 | 100 | #zstyle ':vcs_info:git*' check-for-changes true #too slow |
dcac60d9 | 101 | zstyle ':vcs_info:git*:dotfiles' check-for-changes true |
a6e5a638 | 102 | zstyle ':vcs_info:git*' check-for-staged-changes true |
103 | zstyle ':vcs_info:git*' stagedstr "%F{blue}+" | |
104 | zstyle ':vcs_info:git*' unstagedstr "%F{red}*" | |
e8abe786 | 105 | |
dcac60d9 | 106 | #unset f |
4ebae5dc | 107 | |
d877aef2 | 108 | ### hooks |
ff1a2414 | 109 | local _exectime= |
e8abe786 | 110 | function precmd { |
26a611b7 | 111 | # change terminal title |
d877aef2 | 112 | print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\" |
26a611b7 | 113 | # update vcs |
e8abe786 | 114 | vcs_info |
26a611b7 | 115 | # bell if exec takes 5s |
116 | if ((SECONDS - _exectime >= 5)) print "\a" | |
e8abe786 | 117 | } |
118 | function preexec { | |
26a611b7 | 119 | # change terminal title to show command |
d877aef2 | 120 | print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1" |
26a611b7 | 121 | # save last exec time for bell |
dcac60d9 | 122 | # XXX: does not run for blank cmdline |
e8abe786 | 123 | _exectime=$SECONDS |
124 | } | |
26a611b7 | 125 | function chpwd { |
dcac60d9 | 126 | # echo dir on cwd change |
26a611b7 | 127 | l |
128 | } | |
e8abe786 | 129 | |
ff1a2414 | 130 | ### system-specific configs and aliases |
131 | case "$OSTYPE"; in | |
132 | freebsd*) | |
133 | ## vt binds | |
134 | bindkey "^[[H" beginning-of-line #Home | |
135 | bindkey -a "^[[H" beginning-of-line | |
136 | bindkey "^[[F" end-of-line #End | |
137 | bindkey -a "^[[F" end-of-line | |
d877aef2 | 138 | |
ff1a2414 | 139 | ## sound |
140 | function s { sysctl hw.snd.default_unit${1:+\=$1} } | |
141 | alias vol mixer | |
d877aef2 | 142 | |
ff1a2414 | 143 | ## install port dependencies from pkg (like pkgsrc `bmake bin-install') |
144 | #XXX: should probably use package-depends where possible, breaks when | |
145 | # port name is different to package name | |
146 | # (eg. graphics/sdl20 == sdl2, devel/glib20 == glib2, etc) | |
147 | function portpkg { | |
148 | case "$1" { | |
149 | build|run) | |
150 | sudo pkg install -AU $(make ${1}-depends-list | | |
151 | sed 's_/usr/ports/_ _' | tr -d '\n') | |
152 | ;; | |
153 | *) echo "Usage: \`portpkg <build|run>' in a port directory" | |
154 | return 1;; | |
155 | } | |
156 | };; | |
157 | netbsd) | |
158 | ## sound | |
159 | function s { | |
160 | if [[ -z "$1" ]] { | |
161 | ll /dev/mixer /dev/sound /dev/audio | |
162 | return | |
163 | } | |
164 | for x in mixer sound audio; do | |
165 | ln -sf /dev/$x"$1" /dev/$x | |
166 | done | |
d877aef2 | 167 | } |
ff1a2414 | 168 | function vol { |
169 | if [[ -z "$1" ]] { | |
170 | for x in $(mixerctl -a | grep 'outputs\.master'); do | |
171 | echo $x | |
172 | done | |
173 | return | |
174 | } | |
175 | mixerctl -w outputs.master"$2"="$1" | |
176 | };; | |
dcac60d9 | 177 | *) |
178 | ## sound | |
179 | # TODO: test alsa/oss/sndio/portaudio/pulse in order of importance | |
ff1a2414 | 180 | esac |
d877aef2 | 181 | |
1b8a4102 | 182 | # The following lines were added by compinstall |
183 | zstyle ':completion:*' auto-description 'specify: %d' | |
184 | zstyle ':completion:*' expand suffix | |
185 | zstyle ':completion:*' format '# %d' | |
186 | zstyle ':completion:*' group-name '' | |
187 | zstyle ':completion:*' ignore-parents parent | |
188 | zstyle ':completion:*' insert-unambiguous false | |
189 | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
190 | zstyle ':completion:*' list-prompt '%B%i%b' | |
191 | zstyle ':completion:*' list-suffixes true | |
192 | zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' | |
193 | zstyle ':completion:*' menu select=1 | |
194 | zstyle ':completion:*' original false | |
195 | zstyle ':completion:*' select-prompt '%B%l%b' | |
196 | zstyle ':completion:*' verbose true | |
197 | zstyle :compinstall filename '/home/ds6/.zshrc' | |
198 | ||
199 | autoload -Uz compinit | |
200 | compinit | |
201 | # End of lines added by compinstall | |
202 | ||
03bc64c4 | 203 | # vim: ts=8:sts=4:sw=4:et:tw=79 |