Solved Setting vi mode in .shrc

The default .shrc in a fresh FreeBSD install contains the command set -o vi (which is commented out). Activating this and starting a new shell leads to unstable bevaviour when editing commands – neither standard movement commands nor vi commands work reliably. But when executing set -o vi manually, it works as intended. Also, executing set -o right after logging in has the same effect: It shows the vi mode being active, and afterwards, vi mode does work. What could be the problem here?
 
I've found a PR about this: PR 280889
Ed Maste's comment explains it:

This is caused by the bind commands that exist by default in .~/shrc, e.g.

# csh like history on arrow up and down
bind ^[[A ed-search-prev-history
bind ^[[B ed-search-next-history

With these commands commented out `set -o vi` in .profile functions as expected. This is the same sort of issue described in PR215958.

And Gert Doering's comment:

...

With the "bind" hint, what I came up was "would it work if I move the 'set -o vi' command to the end of '.shrc'" - and lo and behold, it works :-)
 
Back
Top