Skip to content

Instantly share code, notes, and snippets.

@kjm0001
Forked from sebastiancarlos/vi.inputrc
Created July 17, 2023 19:42
Show Gist options
  • Save kjm0001/c6f732137dc7f834059e6d6ad5f89b86 to your computer and use it in GitHub Desktop.
Save kjm0001/c6f732137dc7f834059e6d6ad5f89b86 to your computer and use it in GitHub Desktop.
Add vi mode to your Bash prompt.
# add the contents of this file to ~/.inputrc
# this is where the magic happens
set editing-mode vi
# vi INSERT prompt
set vi-ins-mode-string "\1\e[30;44m\2 INS \1\e[0m\2 "
# vi NORMAL prompt
set vi-cmd-mode-string "\1\e[30;47m\2 NOR \1\e[0m\2 "
# bash is a nice place to mix and match vim and emacs, to find your personal style
$if mode=vi
# bind substring history commands to j and k on vi's command mode
set keymap vi-command
"k": history-substring-search-backward
"j": history-substring-search-forward
# I can't live without C-l to clear the screen
set keymap vi-insert
"\C-l": clear-screen
$endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment