偶然找到的,需要配置好 zsh 和 oh-my-zsh 方可使用。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
| autoload colors colors for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do eval _$color='%{$terminfo[bold]$fg[${(L)color}]%}' eval $color='%{$fg[${(L)color}]%}' (( count = $count + 1 )) done FINISH="%{$terminfo[sgr0]%}"
RPROMPT=$(echo "$RED%D %T$FINISH") PROMPT=$(echo "$CYAN%n@$YELLOW%M:$GREEN%/$_YELLOW>$FINISH ")
case $TERM in (*xterm*|*rxvt*|(dt|k|E)term) precmd () { print -Pn "\e]0;%n@%M//%/\a" } preexec () { print -Pn "\e]0;%n@%M//%/\ $1\a" } ;; esac
export EDITOR=vim
export XMODIFIERS="@im=ibus" export QT_MODULE=ibus export GTK_MODULE=ibus
export HISTSIZE=10000
export SAVEHIST=10000
export HISTFILE=~/.zhistory
setopt INC_APPEND_HISTORY
setopt HIST_IGNORE_DUPS
setopt EXTENDED_HISTORY
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
cd() { builtin cd "$@" fc -W local HISTDIR="$HOME/.zsh_history$PWD" if [ ! -d "$HISTDIR" ] ; then mkdir -p "$HISTDIR" fi export HISTFILE="$HISTDIR/zhistory" touch $HISTFILE local ohistsize=$HISTSIZE HISTSIZE=0 HISTSIZE=$ohistsize fc -R } mkdir -p $HOME/.zsh_history$PWD export HISTFILE="$HOME/.zsh_history$PWD/zhistory" function allhistory { cat $(find $HOME/.zsh_history -name zhistory) } function convhistory { sort $1 | uniq | sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' | awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }' }
function histall { convhistory =(allhistory) | sed '/^.\{20\} *cd/i\\' }
function hist { convhistory $HISTFILE }
function top50 { allhistory | awk -F':[ 0-9]*:[0-9]*;' '{ $1="" ; print }' | sed 's/ /\n/g' | sed '/^$/d' | sort | uniq -c | sort -nr | head -n 50 }
setopt INTERACTIVE_COMMENTS
setopt AUTO_CD
setopt complete_in_word
limit coredumpsize 0
bindkey -e
WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
setopt AUTO_LIST setopt AUTO_MENU
autoload -U compinit compinit
zstyle ':completion:*' verbose yes zstyle ':completion:*' menu select zstyle ':completion:*:*:default' force-list always zstyle ':completion:*' select-prompt '%SSelect: lines: %L matches: %M [%p]' zstyle ':completion:*:match:*' original only zstyle ':completion::prefix-1:*' completer _complete zstyle ':completion:predict:*' completer _complete zstyle ':completion:incremental:*' completer _complete _correct zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate
zstyle ':completion:*' expand 'yes' zstyle ':completion:*' squeeze-shlashes 'yes' zstyle ':completion::complete:*' '\\'
eval $(dircolors -b) export ZLSCOLORS="${LS_COLORS}" zmodload zsh/complist zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' completer _complete _match _approximate zstyle ':completion:*:match:*' original only zstyle ':completion:*:approximate:*' max-errors 1 numeric
compdef pkill=kill compdef pkill=killall zstyle ':completion:*:*:kill:*' menu yes select zstyle ':completion:*:*:*:*:processes' force-list always zstyle ':completion:*:processes' command 'ps -au$USER'
zstyle ':completion:*:matches' group 'yes' zstyle ':completion:*' group-name '' zstyle ':completion:*:options' description 'yes' zstyle ':completion:*:options' auto-description '%d' zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m' zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m' zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m' zstyle ':completion:*:corrections' format $'\e[01;32m -- %d (errors: %e) --\e[0m'
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
zle_highlight=(region:bg=magenta special:bold isearch:underline)#搜索时使用的关键字
user-complete(){ case $BUFFER in "" ) BUFFER="cd " zle end-of-line zle expand-or-complete ;; "cd --" ) BUFFER="cd +" zle end-of-line zle expand-or-complete ;; "cd +-" ) BUFFER="cd -" zle end-of-line zle expand-or-complete ;; * ) zle expand-or-complete ;; esac } zle -N user-complete bindkey "\t" user-complete
sudo-command-line() { [[ -z $BUFFER ]] && zle up-history [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER" zle end-of-line } zle -N sudo-command-line
bindkey "\e\e" sudo-command-line
alias cp='cp -i' alias mv='mv -i' alias rm='rm -i' alias ls='ls -F --color=auto' alias ll='ls -al' alias grep='grep --color=auto' alias la='ls -a' alias pacman='sudo pacman-color' alias p='sudo pacman-color' alias y='yaourt' alias h='htop' alias vim='sudo vim'
alias run-help >&/dev/null && unalias run-help autoload run-help
alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
hash -d A="/media/ayu/dearest" hash -d H="/media/data/backup/ayu" hash -d E="/etc/" hash -d D="/home/ayumi/Documents"
zstyle ':completion:*:ping:*' hosts 192.168.1.{1,50,51,100,101} www.google.com
arith-eval-echo() { LBUFFER="${LBUFFER}echo \$(( " RBUFFER=" ))$RBUFFER" } zle -N arith-eval-echo bindkey "^[[11~" arith-eval-echo
function timeconv { date -d @$1 +"%Y-%m-%d %T" }
zmodload zsh/mathfunc autoload -U zsh-mime-setup zsh-mime-setup setopt EXTENDED_GLOB
setopt correctall autoload compinstall
setopt extended_glob TOKENS_FOLLOWED_BY_COMMANDS=('|' '||' ';' '&' '&&' 'sudo' 'do' 'time' 'strace') recolor-cmd() { region_highlight=() colorize=true start_pos=0 for arg in ${(z)BUFFER}; do ((start_pos+=${#BUFFER[$start_pos+1,-1]}-${#${BUFFER[$start_pos+1,-1]## #}})) ((end_pos=$start_pos+${#arg})) if $colorize; then colorize=false res=$(LC_ALL=C builtin type $arg 2>/dev/null) case $res in *'reserved word'*) style="fg=magenta,bold";; *'alias for'*) style="fg=cyan,bold";; *'shell builtin'*) style="fg=yellow,bold";; *'shell function'*) style='fg=green,bold';; *"$arg is"*) [[ $arg = 'sudo' ]] && style="fg=red,bold" || style="fg=blue,bold";; *) style='none,bold';; esac region_highlight+=("$start_pos $end_pos $style") fi [[ ${${TOKENS_FOLLOWED_BY_COMMANDS[(r)${arg//|/\|}]}:+yes} = 'yes' ]] && colorize=true start_pos=$end_pos done } check-cmd-self-insert() { zle .self-insert && recolor-cmd } check-cmd-backward-delete-char() { zle .backward-delete-char && recolor-cmd } zle -N self-insert check-cmd-self-insert zle -N backward-delete-char check-cmd-backward-delete-char
|