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: Andre Majorel
Subject: Re: Readline : move to previous/next path component
Date: Fri, 17 Oct 2008 11:57:00 +0000 (UTC)
User-agent: slrn/pre0.9.9-97 (Debian)

On 2008-10-16, Larry Clapp <larry@theclapp.org> wrote:
> 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 ]

More precisely, because it's been explicitly unbound :

  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=198634

  | "Marcelo E. Magallon" :
  | Oh, btw, I can't get C-M-j to work.  Perhaps I need to
  | figure out which key is Meta.  I thought it was "Alt" (which
  | xkeycaps confirms), but no cigar...
  |
  | Chet Ramey :
  | It doesn't work in bash.  Bash disables it because `set -o
  | emacs' and `set -o vi' exist.  There is text in the readline
  | manual that is conditionally included depending on whether or
  | not the text is part of the bash manual or standalone.  The
  | standalone version includes the M-C-j stuff; the bash version
  | includes `set -o {emacs,vi}'

If you don't quite see the relationship of cause and effect
implied by the word "because" between "set -o {vi,emacs} exist"
and "Bash disables [M-C-j]", me neither, but there you have it.

> 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'

Thanks, that worked. Put this in my .inputrc (not tested in vi
mode) :

  # [ù] to switch between vi and Emacs mode
  set keymap emacs
  ù: vi-editing-mode
  set keymap vi-command
  ù: emacs-editing-mode
  set keymap vi-insert
  ù: emacs-editing-mode
  set keymap vi-move
  ù: emacs-editing-mode

With this, you can move to the next-to-last path component with

                   [ù] [Esc] [2] [T] [/] [ù]

(7 key presses) instead of the wrist-twisting, console-verboten

       [Esc] [Ctrl]-[]] [/] [Esc] [Ctrl]-[]] [/] [Right]

(13 key presses). Still, not nearly as good as

                     [Ctrl]-[T] [Ctrl]-[T]

(3 key presses).

One problem solved, four to go. <g>

-- 
André Majorel <URL:http://www.teaser.fr/~amajorel/>
You measure democracy by the freedom it gives its dissidents, not
the freedom it gives its assimilated conformists -- Abbie Hoffman.




reply via email to

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