Skip to content
This repository

Key bindings documentation #889

Closed
wants to merge 1 commit into from

3 participants

Kyle West Sorin Ionescu Robby Russell
Kyle West
  • Added documentation to lib/key-bindings.zsh.
  • Added new theme with pretty prompt for vim users.

Sorin Ionescu

I like your command mode indicator. In my theme, I use $RPROMPT, which is overwritten when the line is too long.

Robby Russell
Owner

@kylewest any chance you can rebase this for me?

Kyle West

there you go. I think that's what you meant.

Kyle West kylewest deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 29, 2013
Kyle West kylewest add keybinding documentation. New vim theme. e672930
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 56 additions and 25 deletions. Show diff stats Hide diff stats

  1. +28 25 lib/key-bindings.zsh
  2. +28 0 themes/vim-prompt.zsh-theme
53 lib/key-bindings.zsh
... ... @@ -1,35 +1,38 @@
1   -# TODO: Explain what some of this does..
  1 +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
  2 +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
  3 +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
2 4
3   -bindkey -e
4   -bindkey '\ew' kill-region
5   -bindkey -s '\el' "ls\n"
6   -bindkey -s '\e.' "..\n"
7   -bindkey '^r' history-incremental-search-backward
8   -bindkey "^[[5~" up-line-or-history
9   -bindkey "^[[6~" down-line-or-history
  5 +bindkey -e # Use emacs key bindings
10 6
11   -# make search up and down work, so partially type and hit up/down to find relevant stuff
12   -bindkey '^[[A' up-line-or-search
13   -bindkey '^[[B' down-line-or-search
  7 +bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
  8 +bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
  9 +bindkey -s '\e.' '..\n' # [Esc-.] - run command: .. (up directory)
  10 +bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
  11 +bindkey '^[[5~' up-line-or-history # [PageUp] - Up a line of history
  12 +bindkey '^[[6~' down-line-or-history # [PageDown] - Down a line of history
14 13
15   -bindkey "^[[H" beginning-of-line
16   -bindkey "^[[1~" beginning-of-line
17   -bindkey "^[OH" beginning-of-line
18   -bindkey "^[[F" end-of-line
19   -bindkey "^[[4~" end-of-line
20   -bindkey "^[OF" end-of-line
21   -bindkey ' ' magic-space # also do history expansion on space
  14 +bindkey '^[[A' up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
  15 +bindkey '^[[B' down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
22 16
23   -bindkey "^[[1;5C" forward-word
24   -bindkey "^[[1;5D" backward-word
  17 +bindkey '^[[H' beginning-of-line # [Home] - Go to beginning of line
  18 +bindkey '^[[1~' beginning-of-line # [Home] - Go to beginning of line
  19 +bindkey '^[OH' beginning-of-line # [Home] - Go to beginning of line
  20 +bindkey '^[[F' end-of-line # [End] - Go to end of line
  21 +bindkey '^[[4~' end-of-line # [End] - Go to end of line
  22 +bindkey '^[OF' end-of-line # [End] - Go to end of line
25 23
26   -bindkey '^[[Z' reverse-menu-complete
  24 +bindkey ' ' magic-space # [Space] - do history expansion
  25 +
  26 +bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
  27 +bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
  28 +
  29 +bindkey '^[[Z' reverse-menu-complete # [TODO] - Perform menu completion, like menu-complete, except that if a menu completion is already in progress, move to the previous completion rather than the next.
27 30
28 31 # Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
29   -bindkey '^?' backward-delete-char
30   -bindkey "^[[3~" delete-char
31   -bindkey "^[3;5~" delete-char
32   -bindkey "\e[3~" delete-char
  32 +bindkey '^?' backward-delete-char # [Delete] - delete backward
  33 +bindkey '^[[3~' delete-char # [fn-Delete] - delete forward
  34 +bindkey '^[3;5~' delete-char # [TODO] - delete forward
  35 +bindkey '\e[3~' delete-char # [TODO] - delete forward
33 36
34 37 # consider emacs keybindings:
35 38
28 themes/vim-prompt.zsh-theme
... ... @@ -0,0 +1,28 @@
  1 +function zle-line-init zle-keymap-select {
  2 + zle reset-prompt
  3 +}
  4 +zle -N zle-line-init
  5 +zle -N zle-keymap-select
  6 +
  7 +local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
  8 +
  9 +ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}- %{$fg[yellow]%}["
  10 +ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
  11 +ZSH_THEME_GIT_PROMPT_CLEAN=""
  12 +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[yellow]%}"
  13 +
  14 +ZSH_THEME_VI_MODE_COMMAND="%{$fg_bold[magenta]%}<#%{$reset_color%}"
  15 +ZSH_THEME_VI_MODE_INSERT="%{$fg_bold[green]%}$>%{$reset_color%}"
  16 +
  17 +vi_mode_prompt_info () {
  18 + if [[ ${KEYMAP} = 'vicmd' ]]
  19 + then
  20 + echo $ZSH_THEME_VI_MODE_COMMAND
  21 + else
  22 + echo $ZSH_THEME_VI_MODE_INSERT
  23 + fi
  24 +}
  25 +
  26 +PROMPT='%{$fg[green]%}%c $(git_prompt_info)$(vi_mode_prompt_info) '
  27 +PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
  28 +RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} '

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.