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