Feature description
Brush should support vi style line editing. Currently, brush only supports emacs line editing.
Use case / motivation
I (and other users I know) use vi mode in bash for more efficient line editing.
For many users vi-style line editing is a must-have feature for a shell.
As my standard .bashrc setup includes:
# Vi mode
set -o vi
bind -m vi-insert "\C-l":clear-screen
Proposed solution
Set switch behaviors:
set -o emacs # set vi OFF; set emacs ON
set +o emacs # set emacs OFF
set -o vi # set emacs OFF; set vi ON
set +o vi # set vi OFF
Set switches:
(emacs OFF, vi OFF) => no line editing
(emacs ON, vi OFF) => emacs line editing
(emacs OFF, vi ON ) => vi line editing
(emacs ON, vi ON ) => [NOT possible to set]
Line editing mode should be stored with something like this:
enum LineEditingMode {
/// no line editing (emacs OFF, vi OFF)
None,
// Emacs style line editing (emacs ON, vi OFF)
#[default]
Emacs,
// Vi style line editing (emacs OFF, vi ON)
Vi,
}
Example session of bash --norc showing expected behavior:
bash-5.3$ alias m='set -o | rg -w "vi|emacs"; echo'
bash-5.3$ m # default (emacs)
emacs on
vi off
bash-5.3$ set -o vi # set to vi
bash-5.3$ m
emacs off
vi on
bash-5.3$ set -o emacs # set to back to emacs
bash-5.3$ m
emacs on
vi off
bash-5.3$ set +o emacs # disable line editing (tab inserts tab character)
bash-5.3$ m
emacs off
vi off
Additional context
Bash docs on vi mode:
While the Readline library does not have a full set of vi editing functions, it does contain enough to allow simple editing of the line. The Readline vi mode behaves as specified in the sh description in the POSIX standard.
You can use the set -o emacs and set -o vi commands (see The Set Builtin) to switch interactively between emacs and vi editing modes, The Readline default is emacs mode.
When you enter a line in vi mode, you are already placed in 'insertion' mode, as if you had typed an i. Pressing ESC switches you into 'command' mode, where you can edit the text of the line with the standard vi movement keys, move to previous history lines with k and subsequent lines with j, and so forth.
https://www.gnu.org/software/bash/manual/html_node/Readline-vi-Mode.html
Feature description
Brush should support vi style line editing. Currently, brush only supports emacs line editing.
Use case / motivation
I (and other users I know) use vi mode in bash for more efficient line editing.
For many users vi-style line editing is a must-have feature for a shell.
As my standard
.bashrcsetup includes:Proposed solution
Set switch behaviors:
Set switches:
Line editing mode should be stored with something like this:
Example session of
bash --norcshowing expected behavior:Additional context
Bash docs on vi mode:
https://www.gnu.org/software/bash/manual/html_node/Readline-vi-Mode.html