bug-bash
[Top][All Lists]
Advanced

[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 <address@hidden> wrote:
> > In article <address@hidden>,
> > Andre Majorel  <address@hidden> 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
    address@hidden:~$ bind -m emacs -p | grep -i m-.c-j
    [ no output ]
    address@hidden:~$ bind -m vi -p | grep -i c-e
    [ no output ]

or put another way:

    address@hidden:~$ bind -m emacs -p | grep editing-mode
    # emacs-editing-mode (not bound)
    # vi-editing-mode (not bound)
    address@hidden:~$ 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:

    address@hidden:~$ bind -m emacs '"\e\C-J": vi-editing-mode'
    address@hidden:~$ bind -m vi '"\C-E": emacs-editing-mode'

Check:

    address@hidden:~$ bind -m emacs -p | grep -i m-.c-j
    "\M-\C-j": vi-editing-mode
    address@hidden:~$ bind -m vi -p | grep -i c-e
    "\C-e": emacs-editing-mode

    address@hidden:~$ bind -m emacs -p | grep editing-mode
    # emacs-editing-mode (not bound)
    "\M-\C-j": vi-editing-mode
    address@hidden:~$ 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:

    address@hidden:~$ bind -m emacs '"\M-\C-J": vi-editing-mode'
    address@hidden:~$ 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]