]>
Commit | Line | Data |
---|---|---|
1 | ### options | |
2 | setopt autocd extendedglob | |
3 | unsetopt beep | |
4 | ||
5 | ### history | |
6 | setopt appendhistory | |
7 | HISTFILE=~/.histfile | |
8 | HISTSIZE=100 | |
9 | SAVEHIST=100 | |
10 | ||
11 | ### keys | |
12 | bindkey -v | |
13 | KEYTIMEOUT=1 | |
14 | ## xorg | |
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 | |
21 | ## history search | |
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 | ||
28 | ### aliases | |
29 | alias h="history -25" | |
30 | alias j="jobs -l" | |
31 | alias l="ls -AF" | |
32 | alias ll="ls -lAFho" | |
33 | ## ps | |
34 | local p="ps -aSdxwwouser=USR -ogroup=GRP -opid,nice=N \ | |
35 | -o%cpu,%mem,tt,stat,start=START -oetime,command | ${PAGER:-more} -Se" | |
36 | alias pa="$p" | |
37 | alias spa="sudo $p" | |
38 | unset p | |
39 | ## py venv | |
40 | alias va="source bin/activate" | |
41 | alias vd="deactivate" | |
42 | ## be paranoid | |
43 | alias cp='cp -ip' | |
44 | alias mv='mv -i' | |
45 | if [[ "$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 | |
53 | setopt prompt_subst | |
54 | local f= | |
55 | if [[ "$OSTYPE" = "netbsd" && ( "$TERM" =~ "^wsvt" || "$TERM" =~ '^vt' ) ]] { | |
56 | # fix for wscons | |
57 | f="%F{white}" | |
58 | } else { | |
59 | f="%f" | |
60 | } | |
61 | PROMPT='%F{$VICOL}%n'"$f"'@%F{$VICOL}%2m'"$f"'%(?../%F{red}$?'"$f"')%# ' | |
62 | RPROMPT='%F{yellow}${vcs_info_msg_0_:-%~}'"$f"' %T' | |
63 | ||
64 | ## change color based on zle vi mode | |
65 | function zle-line-init zle-keymap-select { | |
66 | VICOL="${${KEYMAP:/vicmd/red}:/(main|viins)/green}" | |
67 | zle reset-prompt | |
68 | } | |
69 | zle -N zle-line-init | |
70 | zle -N zle-keymap-select | |
71 | ||
72 | ## vcs | |
73 | autoload -Uz vcs_info | |
74 | zstyle ':vcs_info:*' enable git | |
75 | zstyle ':vcs_info:git*' formats '%c%u%%F{green}%r/%b%%F{white}/%%F{yellow}%S%'"$f" | |
76 | zstyle ':vcs_info:git*' actionformats '%%F{red}(%a)'"$f"' %c%u%%F{green}%r/%b'"$f"'/%%F{yellow}%S'"$f" | |
77 | #zstyle ':vcs_info:git*' check-for-changes true #too slow | |
78 | zstyle ':vcs_info:git*:.dotfiles' check-for-changes true | |
79 | zstyle ':vcs_info:git*' check-for-staged-changes true | |
80 | zstyle ':vcs_info:git*' stagedstr "%F{blue}+" | |
81 | zstyle ':vcs_info:git*' unstagedstr "%F{red}*" | |
82 | ||
83 | unset f | |
84 | ||
85 | ### hooks | |
86 | local _exectime= | |
87 | function precmd { | |
88 | # change terminal title | |
89 | print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\" | |
90 | # update vcs | |
91 | vcs_info | |
92 | # bell if exec takes 5s | |
93 | if ((SECONDS - _exectime >= 5)) print "\a" | |
94 | } | |
95 | function preexec { | |
96 | # change terminal title to show command | |
97 | print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1" | |
98 | # save last exec time for bell | |
99 | _exectime=$SECONDS | |
100 | } | |
101 | function chpwd { | |
102 | l | |
103 | } | |
104 | ||
105 | ### system-specific configs and aliases | |
106 | case "$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 | |
113 | ||
114 | ## sound | |
115 | function s { sysctl hw.snd.default_unit${1:+\=$1} } | |
116 | alias vol mixer | |
117 | ||
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 | |
142 | } | |
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 | };; | |
152 | esac | |
153 | ||
154 | # The following lines were added by compinstall | |
155 | zstyle ':completion:*' auto-description 'specify: %d' | |
156 | zstyle ':completion:*' expand suffix | |
157 | zstyle ':completion:*' format '# %d' | |
158 | zstyle ':completion:*' group-name '' | |
159 | zstyle ':completion:*' ignore-parents parent | |
160 | zstyle ':completion:*' insert-unambiguous false | |
161 | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
162 | zstyle ':completion:*' list-prompt '%B%i%b' | |
163 | zstyle ':completion:*' list-suffixes true | |
164 | zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' | |
165 | zstyle ':completion:*' menu select=1 | |
166 | zstyle ':completion:*' original false | |
167 | zstyle ':completion:*' select-prompt '%B%l%b' | |
168 | zstyle ':completion:*' verbose true | |
169 | zstyle :compinstall filename '/home/ds6/.zshrc' | |
170 | ||
171 | autoload -Uz compinit | |
172 | compinit | |
173 | # End of lines added by compinstall | |
174 | ||
175 | # vim: ts=8:sts=4:sw=4:et:tw=79 |