]> git.sev.monster Git - dotfiles.git/blame - base/.zshrc
Merge branch 'master' of home:git/dotfiles
[dotfiles.git] / base / .zshrc
CommitLineData
d877aef2 1### options
12f46d4e 2setopt autocd extendedglob
3unsetopt beep
4
d877aef2 5### path
6# typeset -U makes every array entry unique; /usr/{pkg,local} are bsdisms
7typeset -U path
8path=({~/,/,/usr/}sbin {~/,/,/usr/}bin /usr/pkg/{s,}bin /usr/X11R{7,6}/bin
9 /usr/local/{s,}bin $path)
10
11### history
12f46d4e 12setopt appendhistory
13HISTFILE=~/.histfile
14HISTSIZE=100
15SAVEHIST=100
16
d877aef2 17### keys
12f46d4e 18bindkey -v
e8abe786 19KEYTIMEOUT=1
d877aef2 20## xorg
12f46d4e 21bindkey "^[[7~" beginning-of-line #Home
22bindkey -a "^[[7~" beginning-of-line
23bindkey "^[[8~" end-of-line #End
24bindkey -a "^[[8~" end-of-line
25bindkey "^[[3~" delete-char #Del
26bindkey -a "^[[3~" delete-char
d877aef2 27## history search
12f46d4e 28autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
29zle -N up-line-or-beginning-search
30zle -N down-line-or-beginning-search
31[[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search
32[[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search
33
d877aef2 34### aliases
1b8a4102 35alias h="history -25"
36alias j="jobs -l"
e8abe786 37alias l="ls -AF"
38alias ll="ls -lAFho"
d877aef2 39## ps
e8abe786 40local p="ps -aSdxwwouser=USR -ogroup=GRP -opid,nice=N \
41 -o%cpu,%mem,tt,stat,start=START -oetime,command | ${PAGER:-more} -Se"
42alias pa="$p"
43alias spa="sudo $p"
44unset p
d877aef2 45## py venv
3edfaacd 46alias va="source bin/activate"
ab4fdc87 47alias vd="deactivate"
d877aef2 48## be paranoid
1b8a4102 49alias cp='cp -ip'
50alias mv='mv -i'
d877aef2 51if [[ "$OSTYPE" = "freebsd" ]] {
52 # don't confirm if only a few files are deleted
53 alias rm='rm -I'
54} else {
55 alias rm='rm -i'
118fb6e0 56}
1b8a4102 57
d877aef2 58### prompt
e8abe786 59setopt prompt_subst
d877aef2 60local f
61if [[ "$TERM" = "wsvt25" ]] {
62 # fix for wscons
63 f="%F{white}"
64} else {
65 f="%f"
66}
67PROMPT='%F{$VICOL}%n'"$f"'@%F{$VICOL}%2m'"$f"'%(?../%F{red}$?'"$f"')%# '
68RPROMPT='%F{yellow}${vcs_info_msg_0_:-%~}'"$f"' %T'
e8abe786 69
d877aef2 70## change color based on zle vi mode
e8abe786 71function zle-line-init zle-keymap-select {
72 VICOL="${${KEYMAP:/vicmd/red}:/(main|viins)/green}"
73 zle reset-prompt
74}
75zle -N zle-line-init
76zle -N zle-keymap-select
77
d877aef2 78## vcs
e8abe786 79autoload -Uz vcs_info
80zstyle ':vcs_info:*' enable git
4ebae5dc 81zstyle ':vcs_info:git*' formats '%c%u%%F{green}%r/%b%%F{white}/%%F{yellow}%S%'"$f"
82zstyle ':vcs_info:git*' actionformats '%%F{red}(%a)'"$f"' %c%u%%F{green}%r/%b'"$f"'/%%F{yellow}%S'"$f"
a6e5a638 83#zstyle ':vcs_info:git*' check-for-changes true #too slow
8d4602a1 84zstyle ':vcs_info:git*:.dotfiles' check-for-changes true
a6e5a638 85zstyle ':vcs_info:git*' check-for-staged-changes true
86zstyle ':vcs_info:git*' stagedstr "%F{blue}+"
87zstyle ':vcs_info:git*' unstagedstr "%F{red}*"
e8abe786 88
4ebae5dc 89unset f
90
d877aef2 91### hooks
92local _exectime
e8abe786 93function precmd {
26a611b7 94 # change terminal title
d877aef2 95 print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\"
26a611b7 96 # update vcs
e8abe786 97 vcs_info
26a611b7 98 # bell if exec takes 5s
99 if ((SECONDS - _exectime >= 5)) print "\a"
e8abe786 100}
101function preexec {
26a611b7 102 # change terminal title to show command
d877aef2 103 print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1"
26a611b7 104 # save last exec time for bell
e8abe786 105 _exectime=$SECONDS
106}
26a611b7 107function chpwd {
108 l
109}
e8abe786 110
d877aef2 111### freebsd-specific
112if [[ "$OSTYPE" = "freebsd" ]] {
113 ## vt binds
114 bindkey "^[[H" beginning-of-line #Home
115 bindkey -a "^[[H" beginning-of-line
116 bindkey "^[[F" end-of-line #End
117 bindkey -a "^[[F" end-of-line
118
119 ## oss sound source
120 function s { sysctl hw.snd.default_unit${1:+\=$1} }
121
122 ## install port dependencies from pkg (like pkgsrc `bmake bin-install')
123 function portpkg {
124 case "$1" {
125 build|run)
126 sudo pkg install -AU $(make ${1}-depends-list |
127 sed 's_/usr/ports/_ _' | tr -d '\n')
128 ;;
129 *) echo "Usage: \`portpkg <build|run>' in a port directory"
130 return 1;;
131 }
132 }
133}
134
1b8a4102 135# The following lines were added by compinstall
136zstyle ':completion:*' auto-description 'specify: %d'
137zstyle ':completion:*' expand suffix
138zstyle ':completion:*' format '# %d'
139zstyle ':completion:*' group-name ''
140zstyle ':completion:*' ignore-parents parent
141zstyle ':completion:*' insert-unambiguous false
142zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
143zstyle ':completion:*' list-prompt '%B%i%b'
144zstyle ':completion:*' list-suffixes true
145zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
146zstyle ':completion:*' menu select=1
147zstyle ':completion:*' original false
148zstyle ':completion:*' select-prompt '%B%l%b'
149zstyle ':completion:*' verbose true
150zstyle :compinstall filename '/home/ds6/.zshrc'
151
152autoload -Uz compinit
153compinit
154# End of lines added by compinstall
155
03bc64c4 156# vim: ts=8:sts=4:sw=4:et:tw=79
This page took 0.053209 seconds and 4 git commands to generate.