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