Skip to content

inputrc

G. Bai edited this page Aug 18, 2021 · 7 revisions

inputrc files tend to modify prompt for Bash vi editing mode, which is set in bashrc:

# Use vi editing mode
set -o vi

$INPUTRC

The $INPUTRC environment variable is defined in bashrc:

if [[ '' = "$TMUX" ]]
then
    export INPUTRC=~/.inputrc
else
    export INPUTRC=~/.tmux.inputrc
fi

Which points to different inputrc files depending on if it's a tmux session.

For macOS, inputrc file needs to be loaded manually in bash_profile:

if [[ "$(uname)" == "Darwin" ]]; then
    bind -f $INPUTRC
fi

vi mode string

To use blinking bar in insert mode, and blinking block in command mode:

Bash

See inputrc:

set vi-ins-mode-string "\1\e[5 q\2"
set vi-cmd-mode-string "\1\e[1 q\2"

To add +/: (in magenta) in front of prompt:

set vi-ins-mode-string "\1\e[35m\2+\1\e[0m\2\1\e[5 q\2"
set vi-cmd-mode-string "\1\e[35m\2:\1\e[0m\2\1\e[1 q\2"

tmux

tmux does not need special treatment in this regard. Use the mode-strings above. The following is obsolete.

tmux will only forward escape sequences to the terminal if surrounded by a DCS escape sequence. See tmux.inputrc:

set vi-ins-mode-string "\ePtmux;\e\e[5 q\e\\"
set vi-cmd-mode-string "\ePtmux;\e\e[1 q\e\\"

To add +/: (in magenta) in front of prompt:

set vi-ins-mode-string "\1\e[35m\2+\1\e[0m\2\ePtmux;\e\1\e[5 q\2\e\\"
set vi-cmd-mode-string "\1\e[35m\2:\1\e[0m\2\ePtmux;\e\1\e[1 q\2\e\\"
Clone this wiki locally