]> git.sev.monster Git - dotfiles.git/blame - base/.zshrc
always kludge wscons, ignore fontconig .uuid
[dotfiles.git] / base / .zshrc
CommitLineData
ba63cd01 1### options
7045a58b 2setopt autocd extendedglob
3unsetopt beep
4
ba63cd01 5### history
7045a58b 6setopt appendhistory
7HISTFILE=~/.histfile
8HISTSIZE=100
9SAVEHIST=100
10
ba63cd01 11### keys
7045a58b 12bindkey -v
b3d0247b 13KEYTIMEOUT=1
ba63cd01 14## xorg
7045a58b 15bindkey "^[[7~" beginning-of-line #Home
16bindkey -a "^[[7~" beginning-of-line
17bindkey "^[[8~" end-of-line #End
18bindkey -a "^[[8~" end-of-line
19bindkey "^[[3~" delete-char #Del
20bindkey -a "^[[3~" delete-char
ba63cd01 21## history search
7045a58b 22autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
23zle -N up-line-or-beginning-search
24zle -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
ba63cd01 28### aliases
189288f7 29alias h="history -25"
30alias j="jobs -l"
b3d0247b 31alias l="ls -AF"
32alias ll="ls -lAFho"
ba63cd01 33## ps
b3d0247b 34local p="ps -aSdxwwouser=USR -ogroup=GRP -opid,nice=N \
35 -o%cpu,%mem,tt,stat,start=START -oetime,command | ${PAGER:-more} -Se"
36alias pa="$p"
37alias spa="sudo $p"
38unset p
ba63cd01 39## py venv
ce090b98 40alias va="source bin/activate"
d7ea63a2 41alias vd="deactivate"
ba63cd01 42## be paranoid
189288f7 43alias cp='cp -ip'
44alias mv='mv -i'
f7960c69 45if [[ "$OSTYPE" =~ '^freebsd' ]] {
ba63cd01 46 # don't confirm if only a few files are deleted
47 alias rm='rm -I'
48} else {
49 alias rm='rm -i'
9fddba79 50}
189288f7 51
ba63cd01 52### prompt
b3d0247b 53setopt prompt_subst
f7960c69 54local f=
7197cc5c 55if [[ "$OSTYPE" = "netbsd" && ( "$TERM" =~ "^wsvt" || "$TERM" =~ '^vt' ) ]] {
ba63cd01 56 # fix for wscons
57 f="%F{white}"
58} else {
59 f="%f"
60}
61PROMPT='%F{$VICOL}%n'"$f"'@%F{$VICOL}%2m'"$f"'%(?../%F{red}$?'"$f"')%# '
62RPROMPT='%F{yellow}${vcs_info_msg_0_:-%~}'"$f"' %T'
b3d0247b 63
ba63cd01 64## change color based on zle vi mode
b3d0247b 65function zle-line-init zle-keymap-select {
66 VICOL="${${KEYMAP:/vicmd/red}:/(main|viins)/green}"
67 zle reset-prompt
68}
69zle -N zle-line-init
70zle -N zle-keymap-select
71
ba63cd01 72## vcs
b3d0247b 73autoload -Uz vcs_info
74zstyle ':vcs_info:*' enable git
ff1edfa8 75zstyle ':vcs_info:git*' formats '%c%u%%F{green}%r/%b%%F{white}/%%F{yellow}%S%'"$f"
76zstyle ':vcs_info:git*' actionformats '%%F{red}(%a)'"$f"' %c%u%%F{green}%r/%b'"$f"'/%%F{yellow}%S'"$f"
ba92616c 77#zstyle ':vcs_info:git*' check-for-changes true #too slow
fdff3888 78zstyle ':vcs_info:git*:.dotfiles' check-for-changes true
ba92616c 79zstyle ':vcs_info:git*' check-for-staged-changes true
80zstyle ':vcs_info:git*' stagedstr "%F{blue}+"
81zstyle ':vcs_info:git*' unstagedstr "%F{red}*"
b3d0247b 82
ff1edfa8 83unset f
84
ba63cd01 85### hooks
f7960c69 86local _exectime=
b3d0247b 87function precmd {
8f9c4a17 88 # change terminal title
ba63cd01 89 print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\"
8f9c4a17 90 # update vcs
b3d0247b 91 vcs_info
8f9c4a17 92 # bell if exec takes 5s
93 if ((SECONDS - _exectime >= 5)) print "\a"
b3d0247b 94}
95function preexec {
8f9c4a17 96 # change terminal title to show command
ba63cd01 97 print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1"
8f9c4a17 98 # save last exec time for bell
b3d0247b 99 _exectime=$SECONDS
100}
8f9c4a17 101function chpwd {
102 l
103}
b3d0247b 104
f7960c69 105### system-specific configs and aliases
106case "$OSTYPE"; in
107 freebsd*)
108 ## vt binds
109 bindkey "^[[H" beginning-of-line #Home
110 bindkey -a "^[[H" beginning-of-line
111 bindkey "^[[F" end-of-line #End
112 bindkey -a "^[[F" end-of-line
ba63cd01 113
f7960c69 114 ## sound
115 function s { sysctl hw.snd.default_unit${1:+\=$1} }
116 alias vol mixer
ba63cd01 117
f7960c69 118 ## install port dependencies from pkg (like pkgsrc `bmake bin-install')
119 #XXX: should probably use package-depends where possible, breaks when
120 # port name is different to package name
121 # (eg. graphics/sdl20 == sdl2, devel/glib20 == glib2, etc)
122 function portpkg {
123 case "$1" {
124 build|run)
125 sudo pkg install -AU $(make ${1}-depends-list |
126 sed 's_/usr/ports/_ _' | tr -d '\n')
127 ;;
128 *) echo "Usage: \`portpkg <build|run>' in a port directory"
129 return 1;;
130 }
131 };;
132 netbsd)
133 ## sound
134 function s {
135 if [[ -z "$1" ]] {
136 ll /dev/mixer /dev/sound /dev/audio
137 return
138 }
139 for x in mixer sound audio; do
140 ln -sf /dev/$x"$1" /dev/$x
141 done
ba63cd01 142 }
f7960c69 143 function vol {
144 if [[ -z "$1" ]] {
145 for x in $(mixerctl -a | grep 'outputs\.master'); do
146 echo $x
147 done
148 return
149 }
150 mixerctl -w outputs.master"$2"="$1"
151 };;
152esac
ba63cd01 153
189288f7 154# The following lines were added by compinstall
155zstyle ':completion:*' auto-description 'specify: %d'
156zstyle ':completion:*' expand suffix
157zstyle ':completion:*' format '# %d'
158zstyle ':completion:*' group-name ''
159zstyle ':completion:*' ignore-parents parent
160zstyle ':completion:*' insert-unambiguous false
161zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
162zstyle ':completion:*' list-prompt '%B%i%b'
163zstyle ':completion:*' list-suffixes true
164zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
165zstyle ':completion:*' menu select=1
166zstyle ':completion:*' original false
167zstyle ':completion:*' select-prompt '%B%l%b'
168zstyle ':completion:*' verbose true
169zstyle :compinstall filename '/home/ds6/.zshrc'
170
171autoload -Uz compinit
172compinit
173# End of lines added by compinstall
174
d9362f34 175# vim: ts=8:sts=4:sw=4:et:tw=79
This page took 0.102906 seconds and 4 git commands to generate.