Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save grateful-dev/9c0f094d3f0fd7e2960dc2007aabd708 to your computer and use it in GitHub Desktop.
Save grateful-dev/9c0f094d3f0fd7e2960dc2007aabd708 to your computer and use it in GitHub Desktop.
zsh - set up/down arrows to show only local history
# Set up/down arrows to use local history
bindkey "${key[Up]}" up-line-or-local-history
bindkey "${key[Down]}" down-line-or-local-history
up-line-or-local-history() {
zle set-local-history 1
zle up-line-or-history
zle set-local-history 0
}
zle -N up-line-or-local-history
down-line-or-local-history() {
zle set-local-history 1
zle down-line-or-history
zle set-local-history 0
}
zle -N down-line-or-local-history
# Set CTRL + up/down arrows to use global history (same as up/down does by default)
bindkey "^[[1;5A" up-line-or-history # [CTRL] + Cursor up
bindkey "^[[1;5B" down-line-or-history # [CTRL] + Cursor down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment