bash history and vi mode

bash history and vi mode

am 01.09.2007 18:24:19 von salty_sohal

I'm starting to adjust to using bash after many years of happy korn
shell usage. I like some of the shortcuts in bash but a few things are
driving me nuts. For instance, when I set the shell to vi mode, and
then use the up arrow to get my previous command out of history, bash
seems to be immediately in insert mode. My preference would be in
command mode so I can jump around and edit the line using the vi
navigation commands my fingers know so well. Does anyone know of any
workarounds that won't break the up arrow for other commands?

Thanks,
-Jonathan

Re: bash history and vi mode

am 02.09.2007 17:17:07 von Martin Krischik

salty_sohal@yahoo.com wrote:

> I'm starting to adjust to using bash after many years of happy korn
> shell usage. I like some of the shortcuts in bash but a few things are
> driving me nuts. For instance, when I set the shell to vi mode, and
> then use the up arrow to get my previous command out of history, bash
> seems to be immediately in insert mode. My preference would be in
> command mode so I can jump around and edit the line using the vi
> navigation commands my fingers know so well. Does anyone know of any
> workarounds that won't break the up arrow for other commands?

The bash input controlls are in a file called .inputrc - see info readline
for details. But I have to say that .inputrc isn't all that easy to
understand and difficult to debug as it only read at system start-up.

I for once never liked the bash vi mode (or .inputrc for that matter) and in
the end I moved on to Z-Shell [1] which offer a far better control over the
the way insert and normal mode work. Have a look at my "vim-mode" [2] and
how the bindkey offers a vicmd and viins. If .inputrc offers anything
similar then I never found it. Also since "bindkey" is a normal command it
easier to debug.

As Z-Shell can do almost everything bash can do and a lot more i never
looked back. And since you are a former korn shell user: have a look at [3]
and search for "KSH" ;-)

Martin

[1] http://zsh.dotsrc.org/
[2] http://martin.krischik.com/index.php/Z-Shell/VimMode
[3] http://zsh.dotsrc.org/Doc/Release/zsh_15.html

--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com

Re: bash history and vi mode

am 03.09.2007 18:27:17 von Icarus Sparry

On Sun, 02 Sep 2007 17:17:07 +0200, Martin Krischik wrote:

> salty_sohal@yahoo.com wrote:
>
>> I'm starting to adjust to using bash after many years of happy korn
>> shell usage. I like some of the shortcuts in bash but a few things are
>> driving me nuts. For instance, when I set the shell to vi mode, and
>> then use the up arrow to get my previous command out of history, bash
>> seems to be immediately in insert mode. My preference would be in
>> command mode so I can jump around and edit the line using the vi
>> navigation commands my fingers know so well. Does anyone know of any
>> workarounds that won't break the up arrow for other commands?
>
> The bash input controlls are in a file called .inputrc - see info
> readline for details. But I have to say that .inputrc isn't all that
> easy to understand and difficult to debug as it only read at system
> start-up.

Actually you can tell bash to re-read its inputrc file in a number of
different ways.
1) Using the re-read-init-file function, this is bound to ctrl-x ctrl-r
in the standard emacs mode, but is not bound in vi mode.
2) Using "bind -f .inputrc".
3) Starting a new subshell, e.g.
INPUTRC=test_inputrc bash
will use test_inputrc as the configuration file.

Re: bash history and vi mode

am 07.09.2007 21:58:51 von William Park

salty_sohal@yahoo.com wrote:
> I'm starting to adjust to using bash after many years of happy korn
> shell usage. I like some of the shortcuts in bash but a few things are
> driving me nuts. For instance, when I set the shell to vi mode, and
> then use the up arrow to get my previous command out of history, bash
> seems to be immediately in insert mode. My preference would be in
> command mode so I can jump around and edit the line using the vi
> navigation commands my fingers know so well. Does anyone know of any
> workarounds that won't break the up arrow for other commands?

works both in command mode and in insert mode. So, I suspect
that you're in insert mode to begin with.

--
William Park , Toronto, Canada
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/