Skip to content

Instantly share code, notes, and snippets.

@jamescherti
Last active March 5, 2025 10:13
Show Gist options
  • Select an option

  • Save jamescherti/3b6582c6079ba80e55c9927021d1edc5 to your computer and use it in GitHub Desktop.

Select an option

Save jamescherti/3b6582c6079ba80e55c9927021d1edc5 to your computer and use it in GitHub Desktop.
inputrc: add hjkl bindings to ~/.inputrc (used by the shells bash, sh...).
" Config file: Add lines to ~/.inputrc
" Description: Add hjkl bindings to ~/.inputrc
" (used by the readline and command line
" shells bash, sh...).
" Alt-h: left
" Alt-j: down
" Alt-k: up
" Alt-j: right
" Author: James Cherti
" GitHub Gist: https://gist.github.com/jamescherti/3b6582c6079ba80e55c9927021d1edc5
" License: MIT
# Replace the arrow keys with Alt + hjkl
"\eh": backward-char
"\el": forward-char
"\ek": history-search-backward
"\ej": history-search-forward
# Alt-shift-H and Alt-shift-L (Backward/forward word)
"\eH": backward-word
"\eL": forward-word
# Unbind the arrow keys
"\eOD":""
"\e[D":""
"\eOC":""
"\e[C":""
"\eOA":""
"\e[A":""
"\eOB":""
"\e[B":""
# Unbind the Home/End keys (replaced with Ctrl-b and Ctrl-e)
Control-b: beginning-of-line
Control-e: end-of-line
"\e[1~": ""
"\e[4~": ""
# Unbind the Delete/Insert keys
"\e[3~": ""
"\e[2~": ""
# Unbind the alternate mappings for "page up" and "page down"
"\e[5~": ""
"\e[6~": ""
# Unbind Ctrl-left-arrow and Ctrl-right-arrow for word moving
# (replaced with Alt-Shift-h and Alt-Shift-l)
"\e[1;5C": ""
"\e[1;5D": ""
"\e[5C": ""
"\e[5D": ""
"\e\e[C": ""
"\e\e[D": ""
# Unbind Backspace (replaced with Ctrl-h)
"\C-h": backward-delete-char
"\C-?": ""
# Unbind Enter (replaced with Ctrl-j)
# "\C-j": accept-line
# "\C-m": ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment