Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

@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
Commits on Apr 29, 2013
  1. Kyle West
This page is out of date. Refresh to see the latest.
Showing with 56 additions and 25 deletions.
  1. +28 −25 lib/key-bindings.zsh
  2. +28 −0 themes/vim-prompt.zsh-theme
53 lib/key-bindings.zsh
View
@@ -1,35 +1,38 @@
-# TODO: Explain what some of this does..
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
-bindkey -e
-bindkey '\ew' kill-region
-bindkey -s '\el' "ls\n"
-bindkey -s '\e.' "..\n"
-bindkey '^r' history-incremental-search-backward
-bindkey "^[[5~" up-line-or-history
-bindkey "^[[6~" down-line-or-history
+bindkey -e # Use emacs key bindings
-# make search up and down work, so partially type and hit up/down to find relevant stuff
-bindkey '^[[A' up-line-or-search
-bindkey '^[[B' down-line-or-search
+bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
+bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
+bindkey -s '\e.' '..\n' # [Esc-.] - run command: .. (up directory)
+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.
+bindkey '^[[5~' up-line-or-history # [PageUp] - Up a line of history
+bindkey '^[[6~' down-line-or-history # [PageDown] - Down a line of history
-bindkey "^[[H" beginning-of-line
-bindkey "^[[1~" beginning-of-line
-bindkey "^[OH" beginning-of-line
-bindkey "^[[F" end-of-line
-bindkey "^[[4~" end-of-line
-bindkey "^[OF" end-of-line
-bindkey ' ' magic-space # also do history expansion on space
+bindkey '^[[A' up-line-or-search # start typing + [Up-Arrow] - fuzzy find history forward
+bindkey '^[[B' down-line-or-search # start typing + [Down-Arrow] - fuzzy find history backward
-bindkey "^[[1;5C" forward-word
-bindkey "^[[1;5D" backward-word
+bindkey '^[[H' beginning-of-line # [Home] - Go to beginning of line
+bindkey '^[[1~' beginning-of-line # [Home] - Go to beginning of line
+bindkey '^[OH' beginning-of-line # [Home] - Go to beginning of line
+bindkey '^[[F' end-of-line # [End] - Go to end of line
+bindkey '^[[4~' end-of-line # [End] - Go to end of line
+bindkey '^[OF' end-of-line # [End] - Go to end of line
-bindkey '^[[Z' reverse-menu-complete
+bindkey ' ' magic-space # [Space] - do history expansion
+
+bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
+bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
+
+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.
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
-bindkey '^?' backward-delete-char
-bindkey "^[[3~" delete-char
-bindkey "^[3;5~" delete-char
-bindkey "\e[3~" delete-char
+bindkey '^?' backward-delete-char # [Delete] - delete backward
+bindkey '^[[3~' delete-char # [fn-Delete] - delete forward
+bindkey '^[3;5~' delete-char # [TODO] - delete forward
+bindkey '\e[3~' delete-char # [TODO] - delete forward
# consider emacs keybindings:
28 themes/vim-prompt.zsh-theme
View
@@ -0,0 +1,28 @@
+function zle-line-init zle-keymap-select {
+ zle reset-prompt
+}
+zle -N zle-line-init
+zle -N zle-keymap-select
+
+local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
+
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}- %{$fg[yellow]%}["
+ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[yellow]%}"
+
+ZSH_THEME_VI_MODE_COMMAND="%{$fg_bold[magenta]%}<#%{$reset_color%}"
+ZSH_THEME_VI_MODE_INSERT="%{$fg_bold[green]%}$>%{$reset_color%}"
+
+vi_mode_prompt_info () {
+ if [[ ${KEYMAP} = 'vicmd' ]]
+ then
+ echo $ZSH_THEME_VI_MODE_COMMAND
+ else
+ echo $ZSH_THEME_VI_MODE_INSERT
+ fi
+}
+
+PROMPT='%{$fg[green]%}%c $(git_prompt_info)$(vi_mode_prompt_info) '
+PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
+RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} '
Something went wrong with that request. Please try again.