Reputation: 53
I'm trying to use vi mode in bash. via the .inputrc (on OSX):
set editing-mode vi
In vi insert mode, the right arrow key moves the cursor to the right, but it stops on the last character in the line. If the cursor is past the end of the line, it moves the cursor to the left. So, in sum, the farthest right you can go is to the last character in the line.
$ cd /usr/locl/bin
# Move the cursor to the middle of the line, and fix something there
$ cd /usr/local/bin
# Now move the cursor back to the end, and write a character (/)
$ cd /usr/local/bi/n
As shown above this means you cannot edit the end of the line without going into command mode (and using 'a').
I found an article which seems to indicate the version of readline/bash might be the problem. However I used brew to upgrade bash (GNU bash, version 4.3.42), and even tried to install and link readline (6.3.8), as recommend by that site. But no luck. Its possible the upgrade was done incorrectly.
Note: I'm looking to make readline in bash act near identical to the default (for others who periodically use my terminal), but allow me to use vim mode. This means I don't need workarounds, but fixes.
Upvotes: 5
Views: 875
Reputation: 4137
Answer here: https://unix.stackexchange.com/a/222506/198846
Apparently it's a bug in the bash version shipped with OSX (3.2), it's fixed in 4.3 according to that answer. Use bash --version
to check your bash version.
To fix, update bash, e.g.
macports: sudo port install bash
brew: brew install bash
Once installed bash --version
will show it's updated (assuming standard brew/macports paths at the start of your $PATH)
You then have to change your default login shell (in System Preferences->Users & Groups->right click your user->advanced options->login shell) to the path of the new bash:
(default) macports: /opt/local/bin/bash
(default) brew: /usr/local/bin/bash
Changing the default login shell step is required even if which bash
shows the macports/brew one.
All credit to the answer linked above.
Upvotes: 2
Reputation: 1379
Can't you edit .bashrc itself instead to use vi mode? The command set -o vi
does it in my case (you are in edit mode initially). Also remove the .inputrc edit as the two may actually interact nefariously afterwards.
Upvotes: 0