[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Readline : move to previous/next path component
From: |
Larry Clapp |
Subject: |
Re: Readline : move to previous/next path component |
Date: |
Thu, 16 Oct 2008 10:20:43 -0400 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Thu, Oct 16, 2008 at 09:12:23AM +0000, Andre Majorel wrote:
> On 2008-10-16, Aharon Robbins <arnold@skeeve.com> wrote:
> > In article <mailman.1159.1224118461.25473.bug-bash@gnu.org>,
> > Andre Majorel <cheney@halliburton.com> wrote:
> >>Vi mode would help, but in Bash, there's no way to switch between
> >>it and Emacs mode on the fly.
> >
> > Au contraire:
> >
> > set -o vi
> > set -o emacs
>
> By "on the fly", I didn't mean in the middle of a Bash session but
> in the middle of editing a command line. For some reason, Esc ^J is
> a no-op in Bash.
That's because it's not bound:
zsh> bash
lmc@cupid:~$ bind -m emacs -p | grep -i m-.c-j
[ no output ]
lmc@cupid:~$ bind -m vi -p | grep -i c-e
[ no output ]
or put another way:
lmc@cupid:~$ bind -m emacs -p | grep editing-mode
# emacs-editing-mode (not bound)
# vi-editing-mode (not bound)
lmc@cupid:~$ bind -m vi -p | grep editing-mode
# emacs-editing-mode (not bound)
# vi-editing-mode (not bound)
But you can bind the standard Readline keys for those commands:
lmc@cupid:~$ bind -m emacs '"\e\C-J": vi-editing-mode'
lmc@cupid:~$ bind -m vi '"\C-E": emacs-editing-mode'
Check:
lmc@cupid:~$ bind -m emacs -p | grep -i m-.c-j
"\M-\C-j": vi-editing-mode
lmc@cupid:~$ bind -m vi -p | grep -i c-e
"\C-e": emacs-editing-mode
lmc@cupid:~$ bind -m emacs -p | grep editing-mode
# emacs-editing-mode (not bound)
"\M-\C-j": vi-editing-mode
lmc@cupid:~$ bind -m vi -p | grep editing-mode
"\C-e": emacs-editing-mode
# vi-editing-mode (not bound)
I could not get "bind -m emacs '"\M-\C-J: vi-editing-mode' to work
directly, it always came out like this:
lmc@cupid:~$ bind -m emacs '"\M-\C-J": vi-editing-mode'
lmc@cupid:~$ bind -q vi-editing-mode | less
vi-editing-mode can be invoked via "<DC>C-J".
# ^^^^
so I'm probably missing some subtle Readline meta-related setting.
Note that the editing mode is not reset when you finish the current
command, but changed permanently. Keeping straight which mode you're
in is left as an exercise to the reader.
-- Larry