zsh vi keybindings

This commit is contained in:
David Chen 2019-10-31 12:53:48 -07:00
parent 0e027eeada
commit d6048e2831
3 changed files with 52 additions and 89 deletions

View file

@ -331,6 +331,7 @@ map gfr cd ~/.config/ranger
map gfn cd ~/.config/nvim
map gfw cd ~/.config/awesome
map gfd cd ~/prog/dwm/
map gfs cd ~/prog/st/
map gfz cd ~/.config/zsh
map gs cd ~/scripts
map ge cd /etc

View file

@ -1,89 +0,0 @@
## Enable colors and change prompt:
#autoload -U colors && colors
#PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
## History in cache directory:
#HISTSIZE=10000
#SAVEHIST=10000
#HISTFILE=~/.cache/zsh/history
## Basic auto/tab complete:
#autoload -U compinit
#zstyle ':completion:*' menu select
#zmodload zsh/complist
#compinit
#_comp_options+=(globdots) # Include hidden files.
## vi mode
#bindkey -v
#export KEYTIMEOUT=1
## Use vim keys in tab complete menu:
#bindkey -M menuselect 'n' vi-backward-char
#bindkey -M menuselect 'u' vi-up-line-or-history
#bindkey -M menuselect 'i' vi-forward-char
#bindkey -M menuselect 'e' vi-down-line-or-history
#bindkey -v '^?' backward-delete-char
## Change cursor shape for different vi modes.
#function zle-keymap-select {
#if [[ ${KEYMAP} == vicmd ]] ||
#[[ $1 = 'block' ]]; then
#echo -ne '\e[1 q'
#elif [[ ${KEYMAP} == main ]] ||
#[[ ${KEYMAP} == viins ]] ||
#[[ ${KEYMAP} = '' ]] ||
#[[ $1 = 'beam' ]]; then
#echo -ne '\e[5 q'
#fi
#}
#zle -N zle-keymap-select
#zle-line-init() {
#zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
#echo -ne "\e[5 q"
#}
#zle -N zle-line-init
#echo -ne '\e[5 q' # Use beam shape cursor on startup.
#preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
## Use lf to switch directories and bind it to ctrl-o
#lfcd () {
#tmp="$(mktemp)"
#lf -last-dir-path="$tmp" "$@"
#if [ -f "$tmp" ]; then
#dir="$(cat "$tmp")"
#rm -f "$tmp"
#[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
#fi
#}
#bindkey -s '^o' 'lfcd\n'
## Edit line in vim with ctrl-e:
autoload edit-command-line; zle -N edit-command-line
bindkey '^v' edit-command-line
# Load aliases and shortcuts if existent.
#[ -f "$HOME/.config/shortcutrc" ] && source "$HOME/.config/shortcutrc"
#[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
#alias av='source venv/bin/activate.fish'
alias c='clear'
alias cdiff='colordiff'
alias cs='cowsay'
#alias dv='deactivate'
alias gc='git config credential.helper store'
alias ipy='ipython'
alias l='ls -la'
alias lg='lazygit'
alias ms='mailsync'
alias mt='neomutt'
alias nv='nvim'
alias ra='ranger'
alias s='neofetch'
alias sra='sudo -E ranger'
alias sudo='sudo -E'
alias vim='nvim'
alias unity='./Downloads/UnityHub.AppImage'
alias gs='git config credential.helper store'

51
zsh/zshrc Normal file
View file

@ -0,0 +1,51 @@
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
export TERM=xterm-256color
#autoload edit-command-line; zle -N edit-command-line
#bindkey '^v' edit-command-line
#alias av='source venv/bin/activate.fish'
alias c='clear'
alias cdiff='colordiff'
alias cs='cowsay'
#alias dv='deactivate'
alias gc='git config credential.helper store'
alias ipy='ipython'
alias l='ls -la'
alias lg='lazygit'
alias ms='mailsync'
alias mt='neomutt'
alias nv='nvim'
alias ra='ranger'
alias s='neofetch'
alias sra='sudo -E ranger'
alias sudo='sudo -E'
alias vim='nvim'
alias gs='git config credential.helper store'
bindkey -v
bindkey -M vicmd "k" vi-insert
bindkey -M vicmd "K" vi-insert-bol
bindkey -M vicmd "n" vi-backward-char
bindkey -M vicmd "i" vi-forward-char
bindkey -M vicmd "N" vi-beginning-of-line
bindkey -M vicmd "I" vi-end-of-line
bindkey -M vicmd "e" down-line-or-history
bindkey -M vicmd "u" up-line-or-history
bindkey -M vicmd "l" undo
#bindkey -M vicmd "-" vi-rev-repeat-search
bindkey -M vicmd "=" vi-repeat-search
bindkey -M vicmd "h" vi-forward-word-end
function zle-line-init zle-keymap-select {
RPS1="${${KEYMAP/vicmd/-- NOR --}/(main|viins)/-- INS --}"
RPS2=$RPS1
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
KEYTIMEOUT=1