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