.zshrc (2182B)
1 # Enable colors and change prompt: 2 autoload -U colors && colors # Load colors 3 PS1="%B%{$fg[green]%}[%{$fg[green]%}%n%{$fg[green]%}@%{$fg[green]%}%M %{$fg[white]%}%~%{$fg[green]%}]%{$reset_color%}$%b " 4 stty stop undef # Disable ctrl-s to freeze terminal. 5 6 # History in cache directory: 7 HISTSIZE=10000 8 SAVEHIST=10000 9 HISTFILE="$XDG_CACHE_HOME/zsh/history" 10 11 # Load aliases 12 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/aliasrc" 13 14 # Basic auto/tab complete: 15 autoload -U compinit 16 zstyle ':completion:*' menu select 17 zmodload zsh/complist 18 compinit 19 _comp_options+=(globdots) # Include hidden files. 20 21 # vi mode 22 bindkey -v 23 export KEYTIMEOUT=1 24 25 # Use vim keys in tab complete menu: 26 bindkey -M menuselect 'h' vi-backward-char 27 bindkey -M menuselect 'k' vi-up-line-or-history 28 bindkey -M menuselect 'l' vi-forward-char 29 bindkey -M menuselect 'j' vi-down-line-or-history 30 bindkey -v '^?' backward-delete-char 31 32 # Change cursor shape for different vi modes. 33 function zle-keymap-select { 34 if [[ ${KEYMAP} == vicmd ]] || 35 [[ $1 = 'block' ]]; then 36 echo -ne 'e[1 q' 37 elif [[ ${KEYMAP} == main ]] || 38 [[ ${KEYMAP} == viins ]] || 39 [[ ${KEYMAP} = '' ]] || 40 [[ $1 = 'beam' ]]; then 41 echo -ne 'e[5 q' 42 fi 43 } 44 45 zle -N zle-keymap-select 46 zle-line-init() { 47 zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) 48 echo -ne "e[5 q" 49 } 50 51 zle -N zle-line-init 52 echo -ne 'e[5 q' # Use beam shape cursor on startup. 53 preexec() { echo -ne 'e[5 q' ;} # Use beam shape cursor for each new prompt. 54 55 # Use lf to switch directories and bind it to ctrl-o 56 lfcd () { 57 tmp="$(mktemp)" 58 lf -last-dir-path="$tmp" "$@" 59 if [ -f "$tmp" ]; then 60 dir="$(cat "$tmp")" 61 rm -f "$tmp" >/dev/null 62 [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" 63 fi 64 } 65 66 bindkey -s '^o' 'lfcdn' 67 68 bindkey '^[[P' delete-char 69 70 # Edit line in vim with ctrl-e: 71 autoload edit-command-line; zle -N edit-command-line 72 bindkey '^e' edit-command-line 73 74 # Load syntax highlighting; should be last. 75 source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh 2>/dev/null