nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

keybindings (2721B)


      1 #!/bin/zsh
      2 
      3 [[ -z "$terminfo[kdch1]" ]] || bindkey -M emacs "$terminfo[kdch1]" delete-char
      4 [[ -z "$terminfo[khome]" ]] || bindkey -M emacs "$terminfo[khome]" beginning-of-line
      5 [[ -z "$terminfo[kend]" ]] || bindkey -M emacs "$terminfo[kend]" end-of-line
      6 [[ -z "$terminfo[kich1]" ]] || bindkey -M emacs "$terminfo[kich1]" overwrite-mode
      7 [[ -z "$terminfo[kdch1]" ]] || bindkey -M vicmd "$terminfo[kdch1]" vi-delete-char
      8 [[ -z "$terminfo[khome]" ]] || bindkey -M vicmd "$terminfo[khome]" vi-beginning-of-line
      9 [[ -z "$terminfo[kend]" ]] || bindkey -M vicmd "$terminfo[kend]" vi-end-of-line
     10 [[ -z "$terminfo[kich1]" ]] || bindkey -M vicmd "$terminfo[kich1]" overwrite-mode
     11 
     12 [[ -z "$terminfo[cuu1]" ]] || bindkey -M viins "$terminfo[cuu1]" vi-up-line-or-history
     13 [[ -z "$terminfo[cuf1]" ]] || bindkey -M viins "$terminfo[cuf1]" vi-forward-char
     14 [[ -z "$terminfo[kcuu1]" ]] || bindkey -M viins "$terminfo[kcuu1]" vi-up-line-or-history
     15 [[ -z "$terminfo[kcud1]" ]] || bindkey -M viins "$terminfo[kcud1]" vi-down-line-or-history
     16 [[ -z "$terminfo[kcuf1]" ]] || bindkey -M viins "$terminfo[kcuf1]" vi-forward-char
     17 [[ -z "$terminfo[kcub1]" ]] || bindkey -M viins "$terminfo[kcub1]" vi-backward-char
     18 
     19 [[ "$terminfo[kcuu1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcuu1]/O/[}" vi-up-line-or-history
     20 [[ "$terminfo[kcud1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcud1]/O/[}" vi-down-line-or-history
     21 [[ "$terminfo[kcuf1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcuf1]/O/[}" vi-forward-char
     22 [[ "$terminfo[kcub1]" == "^[O"* ]] && bindkey -M viins "${terminfo[kcub1]/O/[}" vi-backward-char
     23 [[ "$terminfo[khome]" == "^[O"* ]] && bindkey -M viins "${terminfo[khome]/O/[}" beginning-of-line
     24 [[ "$terminfo[kend]" == "^[O"* ]] && bindkey -M viins "${terminfo[kend]/O/[}" end-of-line
     25 [[ "$terminfo[khome]" == "^[O"* ]] && bindkey -M emacs "${terminfo[khome]/O/[}" beginning-of-line
     26 [[ "$terminfo[kend]" == "^[O"* ]] && bindkey -M emacs "${terminfo[kend]/O/[}" end-of-line
     27 
     28 if [[ -n ${terminfo[smkx]} ]]; then
     29 	zle-line-init() {
     30 		echoti smkx
     31 	}
     32 	zle -N zle-line-init
     33 fi
     34 
     35 if [[ -n ${terminfo[rmkx]} ]]; then
     36 	zle-line-finish() {
     37 		echoti rmkx
     38 	}
     39 	zle -N zle-line-finish
     40 fi
     41 
     42 bindkey -e
     43 
     44 bindkey "$(tput kcuu1)" history-beginning-search-backward
     45 bindkey "$(tput kcud1)" history-beginning-search-forward
     46 
     47 # tmux doesn't handle these, see xterm_keys_modifiers in xterm-keys.c
     48 shift_left=$(tput kLFT 2>/dev/null)
     49 [[ $shift_left ]] && bindkey "$shift_left" backward-word
     50 
     51 shift_right=$(tput kRIT 2>/dev/null)
     52 [[ $shift_right ]] && bindkey "$shift_right" forward-word
     53 
     54 zle -N fzf_copy_from_cliphist
     55 
     56 bindkey '^J' 'fzf_copy_from_cliphist'
     57 bindkey '^F' 'magdalena_goto_file'
     58 bindkey '^K' 'magdalena_goto_dir'
     59 bindkey '^G' 'magdalena_favorites'