diff options
author | johannst <stoelp@eit.uni-kl.de> | 2018-05-27 22:42:57 +0200 |
---|---|---|
committer | johannst <stoelp@eit.uni-kl.de> | 2018-05-27 22:42:57 +0200 |
commit | 41190507f28ee71d8907a4f9a0fc9bdf56a85a7f (patch) | |
tree | c0d5fb92005e430158320952199eaec2b2e55276 /zshrc | |
parent | e6b979acb8621854a2e8235feb78528ce5c0741e (diff) | |
download | dotfiles-41190507f28ee71d8907a4f9a0fc9bdf56a85a7f.tar.gz dotfiles-41190507f28ee71d8907a4f9a0fc9bdf56a85a7f.zip |
Cleaned & improved zshrc
Diffstat (limited to 'zshrc')
-rw-r--r-- | zshrc | 110 |
1 files changed, 89 insertions, 21 deletions
@@ -1,6 +1,9 @@ -# Created by newuser for 4.3.10 +# dotfiles -- zshrc +# author: johannst -typeset -g -A key +# Key definition + +typeset -A key key[Up]="\e[A" key[Down]="\e[B" key[ShiftTab]="\e[Z" @@ -8,43 +11,108 @@ key[CtrlA]="\Ca" key[CtrlE]="\Ce" key[CtrlR]="\Cr" key[CtrlS]="\Cs" +key[CtrlW]="\Cw" +key[BackSpace]="\C?" + +# Basic settings + +setopt correctall +setopt hist_ignore_all_dups + +# Basic alias + +alias ls='\ls --color=auto --classify' +alias ll='\ls --color=auto --classify -l' +alias la='\ls --color=auto --classify --almost-all' +alias lt='\ls --color=auto --classify -l -t --reverse' +alias grep='\grep --color=auto -HIn' +alias rgrep='\grep --color=auto -HIrn' +alias fn='_findName' +function _findName() { + [[ -z $1 ]] && { echo "_findName pattern [path [action]]"; return } || { n=$1; shift } + [[ -z $1 ]] && p=. || { p=$1; shift } + [[ -z $1 ]] && find $p -name $n || find $p -name $n -exec $@ {} \; +} + +# History HISTFILE=~/.zshist HISTSIZE=1000 SAVEHIST=1000 -autoload -Uz promptinit && promptinit -prompt walters +# Prompt + +#autoload -Uz promptinit && promptinit +#prompt walters + +# Completion autoload -Uz compinit && compinit zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}" zstyle ':completion:*' menu select -bindkey -v +zmodload zsh/complist +bindkey -M menuselect "$key[ShiftTab]" reverse-menu-complete -autoload -Uz up-line-or-beginning-search down-line-or-beginning-search -zle -N up-line-or-beginning-search -zle -N down-line-or-beginning-search +# Key mappings + +autoload -Uz up-line-or-beginning-search && zle -N up-line-or-beginning-search +autoload -Uz down-line-or-beginning-search && zle -N down-line-or-beginning-search + +[[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search || echo FALE +[[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search || echo FALE + +# Vi mode + +bindkey -v bindkey -M vicmd "k" up-line-or-beginning-search bindkey -M vicmd "j" down-line-or-beginning-search bindkey -M viins "jj" vi-cmd-mode -bindkey -M vicmd "$key[CtrlA]" vi-digit-or-beginning-of-line -bindkey -M vicmd "$key[CtrlE]" vi-end-of-line -bindkey -M viins "$key[CtrlA]" vi-digit-or-beginning-of-line -bindkey -M viins "$key[CtrlE]" vi-end-of-line +[[ -n "$key[CtrlA]" ]] && bindkey -M vicmd "$key[CtrlA]" vi-digit-or-beginning-of-line +[[ -n "$key[CtrlA]" ]] && bindkey -M viins "$key[CtrlA]" vi-digit-or-beginning-of-line +[[ -n "$key[CtrlE]" ]] && bindkey -M vicmd "$key[CtrlE]" vi-end-of-line +[[ -n "$key[CtrlE]" ]] && bindkey -M viins "$key[CtrlE]" vi-end-of-line -bindkey -M viins "$key[CtrlR]" history-incremental-search-backward -bindkey -M viins "$key[CtrlS]" history-incremental-search-forward +[[ -n "$key[CtrlR]" ]] && bindkey -M viins "$key[CtrlR]" history-incremental-search-backward +[[ -n "$key[CtrlS]" ]] && bindkey -M viins "$key[CtrlS]" history-incremental-search-forward -[[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" up-line-or-beginning-search || echo FALE -[[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" down-line-or-beginning-search || echo FALE +[[ -n "$key[CtrlW]" ]] && bindkey -M viins "$key[CtrlW]" backward-kill-word +[[ -n "$key[BackSpace]" ]] && bindkey -M viins "$key[BackSpace]" backward-delete-char -zmodload zsh/complist -bindkey -M menuselect "$key[ShiftTab]" reverse-menu-complete +# Dirstack + +DIRSTACKSIZE=8 +setopt autopushd pushdminus pushdsilent pushdtohome +alias dh='dirs -v' + +# Prompt + +typeset -A color +color[noColor]='%f' +color[darkGray]='%F{242}' +color[mediumGray]='%F{246}' +color[lightGray]='%F{252}' +color[brightRed]='%F{196}' +color[pinkRed]='%F{125}' +color[babyBlue]='%F{38}' +color[darkBlue]='%F{26}' + +function _installMyPrompt() { + function zle-line-init zle-keymap-select { + vinorm='n' + viins='i' + vimode="${${KEYMAP/vicmd/$color[pinkRed]$vinorm}/(main|viins)/$color[babyBlue]$viins}$color[noColor]" + PS1="$color[mediumGray]%n$color[brightRed]::$color[lightGray]%m$color[brightRed]:$color[darkGray]%l$color[noColor] [$vimode] $color[brightRed]%(?..%? )$color[noColor]> " + RPS1="%F$color[darkBlue]%~%f" + zle reset-prompt + } + + zle -N zle-line-init + zle -N zle-keymap-select +} -#setopt PRINT_EXIT_VALUE +_installMyPrompt -#source ~/local/completion/fd/_fd -#source ~/local/completion/rg/_rg +#% vim:et:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1 |