Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to configure bash vi mode so that initially it is in command mode instead on insert mode? I find that I have to press Esc far too much. It seems that there is possibility to specify this in zsh, but I have not found a way to do this in bash/readline.

share|improve this question

4 Answers 4

I don't think it is possible using the standard GNU Readline Library.

However, you may be able to use xdotool for a simple hack to achieve the same effect. Appending a command to your .bashrc that simulates an Escape keypress would ensure that your term opened in command mode:

xdotool key Escape

You might want to use a slight delay, with the --delay switch, to prevent it from munging your prompt...

Note this is likely to introduce more frustration than you expect: terminals are designed to accept input; breaking that (albeit only slightly) may not prove such a good idea...

share|improve this answer

I take it back, this doesn't work with the cursor movement. It works, but with the funny behavior, if you take those out: PS1="$PS1 ^[


Change your PS1 prompt:

PS1="test $ \[^[[s^[^[[u\]"

Where ^[ is a literal escape (Ctrl+V Esc).

The escape on its own in the middle changes to command mode, the ^[[s and ^[[u escapes store and restore the cursor position; without that, I found there was some funny behavior.

share|improve this answer

The answer is no. The relevant bash source file is bashline.c

share|improve this answer

try set +o vi

set -o vi will take into editing mode again.

http://tldp.org/LDP/abs/html/options.html

share|improve this answer
    
That doesn't work: it turns vi mode off... –  jasonwryan Dec 1 '11 at 8:41
    
yeah I tried. Right. I can think of this -- using vim, change the cmap (reference :help mode-switching in vim) for Esc key. Default equivalent mapping for Esc is Ctrl + ] –  Nikhil Mulley Dec 1 '11 at 8:55
    
Doesn't work on my ksh88 either. –  rahmu Dec 1 '11 at 8:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.