]>
Commit | Line | Data |
---|---|---|
ba63cd01 | 1 | ### options |
7045a58b | 2 | setopt autocd extendedglob |
3 | unsetopt beep | |
4 | ||
ba63cd01 | 5 | ### path |
6 | # typeset -U makes every array entry unique; /usr/{pkg,local} are bsdisms | |
7 | typeset -U path | |
8 | path=({~/,/,/usr/}sbin {~/,/,/usr/}bin /usr/pkg/{s,}bin /usr/X11R{7,6}/bin | |
9 | /usr/local/{s,}bin $path) | |
10 | ||
11 | ### history | |
7045a58b | 12 | setopt appendhistory |
13 | HISTFILE=~/.histfile | |
14 | HISTSIZE=100 | |
15 | SAVEHIST=100 | |
16 | ||
ba63cd01 | 17 | ### keys |
7045a58b | 18 | bindkey -v |
b3d0247b | 19 | KEYTIMEOUT=1 |
ba63cd01 | 20 | ## xorg |
7045a58b | 21 | bindkey "^[[7~" beginning-of-line #Home |
22 | bindkey -a "^[[7~" beginning-of-line | |
23 | bindkey "^[[8~" end-of-line #End | |
24 | bindkey -a "^[[8~" end-of-line | |
25 | bindkey "^[[3~" delete-char #Del | |
26 | bindkey -a "^[[3~" delete-char | |
ba63cd01 | 27 | ## history search |
7045a58b | 28 | autoload -Uz up-line-or-beginning-search down-line-or-beginning-search |
29 | zle -N up-line-or-beginning-search | |
30 | zle -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 | ||
ba63cd01 | 34 | ### aliases |
189288f7 | 35 | alias h="history -25" |
36 | alias j="jobs -l" | |
b3d0247b | 37 | alias l="ls -AF" |
38 | alias ll="ls -lAFho" | |
ba63cd01 | 39 | ## ps |
b3d0247b | 40 | local p="ps -aSdxwwouser=USR -ogroup=GRP -opid,nice=N \ |
41 | -o%cpu,%mem,tt,stat,start=START -oetime,command | ${PAGER:-more} -Se" | |
42 | alias pa="$p" | |
43 | alias spa="sudo $p" | |
44 | unset p | |
ba63cd01 | 45 | ## py venv |
ce090b98 | 46 | alias va="source bin/activate" |
d7ea63a2 | 47 | alias vd="deactivate" |
ba63cd01 | 48 | ## be paranoid |
189288f7 | 49 | alias cp='cp -ip' |
50 | alias mv='mv -i' | |
ba63cd01 | 51 | if [[ "$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' | |
9fddba79 | 56 | } |
189288f7 | 57 | |
ba63cd01 | 58 | ### prompt |
b3d0247b | 59 | setopt prompt_subst |
ba63cd01 | 60 | local f |
61 | if [[ "$TERM" = "wsvt25" ]] { | |
62 | # fix for wscons | |
63 | f="%F{white}" | |
64 | } else { | |
65 | f="%f" | |
66 | } | |
67 | PROMPT='%F{$VICOL}%n'"$f"'@%F{$VICOL}%2m'"$f"'%(?../%F{red}$?'"$f"')%# ' | |
68 | RPROMPT='%F{yellow}${vcs_info_msg_0_:-%~}'"$f"' %T' | |
b3d0247b | 69 | |
ba63cd01 | 70 | ## change color based on zle vi mode |
b3d0247b | 71 | function zle-line-init zle-keymap-select { |
72 | VICOL="${${KEYMAP:/vicmd/red}:/(main|viins)/green}" | |
73 | zle reset-prompt | |
74 | } | |
75 | zle -N zle-line-init | |
76 | zle -N zle-keymap-select | |
77 | ||
ba63cd01 | 78 | ## vcs |
b3d0247b | 79 | autoload -Uz vcs_info |
80 | zstyle ':vcs_info:*' enable git | |
ff1edfa8 | 81 | zstyle ':vcs_info:git*' formats '%c%u%%F{green}%r/%b%%F{white}/%%F{yellow}%S%'"$f" |
82 | zstyle ':vcs_info:git*' actionformats '%%F{red}(%a)'"$f"' %c%u%%F{green}%r/%b'"$f"'/%%F{yellow}%S'"$f" | |
ba92616c | 83 | #zstyle ':vcs_info:git*' check-for-changes true #too slow |
fdff3888 | 84 | zstyle ':vcs_info:git*:.dotfiles' check-for-changes true |
ba92616c | 85 | zstyle ':vcs_info:git*' check-for-staged-changes true |
86 | zstyle ':vcs_info:git*' stagedstr "%F{blue}+" | |
87 | zstyle ':vcs_info:git*' unstagedstr "%F{red}*" | |
b3d0247b | 88 | |
ff1edfa8 | 89 | unset f |
90 | ||
ba63cd01 | 91 | ### hooks |
92 | local _exectime | |
b3d0247b | 93 | function precmd { |
8f9c4a17 | 94 | # change terminal title |
ba63cd01 | 95 | print -Pn "\e]2;%(1j,%j,)%#${SSH_CLIENT+$USER@$HOST:}%~\e\\" |
8f9c4a17 | 96 | # update vcs |
b3d0247b | 97 | vcs_info |
8f9c4a17 | 98 | # bell if exec takes 5s |
99 | if ((SECONDS - _exectime >= 5)) print "\a" | |
b3d0247b | 100 | } |
101 | function preexec { | |
8f9c4a17 | 102 | # change terminal title to show command |
ba63cd01 | 103 | print -Pnf "\e]2;%s\e\\" "%#${SSH_CLIENT+$USER@$HOST:}$1" |
8f9c4a17 | 104 | # save last exec time for bell |
b3d0247b | 105 | _exectime=$SECONDS |
106 | } | |
8f9c4a17 | 107 | function chpwd { |
108 | l | |
109 | } | |
b3d0247b | 110 | |
ba63cd01 | 111 | ### freebsd-specific |
112 | if [[ "$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 | ||
189288f7 | 135 | # The following lines were added by compinstall |
136 | zstyle ':completion:*' auto-description 'specify: %d' | |
137 | zstyle ':completion:*' expand suffix | |
138 | zstyle ':completion:*' format '# %d' | |
139 | zstyle ':completion:*' group-name '' | |
140 | zstyle ':completion:*' ignore-parents parent | |
141 | zstyle ':completion:*' insert-unambiguous false | |
142 | zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} | |
143 | zstyle ':completion:*' list-prompt '%B%i%b' | |
144 | zstyle ':completion:*' list-suffixes true | |
145 | zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._-]=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' | |
146 | zstyle ':completion:*' menu select=1 | |
147 | zstyle ':completion:*' original false | |
148 | zstyle ':completion:*' select-prompt '%B%l%b' | |
149 | zstyle ':completion:*' verbose true | |
150 | zstyle :compinstall filename '/home/ds6/.zshrc' | |
151 | ||
152 | autoload -Uz compinit | |
153 | compinit | |
154 | # End of lines added by compinstall | |
155 | ||
d9362f34 | 156 | # vim: ts=8:sts=4:sw=4:et:tw=79 |