"alt-period" (alt-.) when previous command was backgrounded with &

View: New views
6 Messages — Rating Filter:   Alert me  

"alt-period" (alt-.) when previous command was backgrounded with &

by Sitaram Chamarty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

When the previous command was backgrounded (say "gvim
filename.c &") and then you try some other command using
Alt-., it expands to "&" and not "filename.c".

Is this considered a bug?  Or correct behaviour that just
happens to be not useful in this specific case?

Thanks,

Sitaram




Re: "alt-period" (alt-.) when previous command was backgrounded with &

by Chet Ramey :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sitaram Chamarty wrote:
> Hello,
>
> When the previous command was backgrounded (say "gvim
> filename.c &") and then you try some other command using
> Alt-., it expands to "&" and not "filename.c".
>
> Is this considered a bug?  Or correct behaviour that just
> happens to be not useful in this specific case?

M-. uses the last word from the previous line.  If that happens to
be `&', that's what it uses.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@...    http://cnswww.cns.cwru.edu/~chet/



Re: "alt-period" (alt-.) when previous command was backgrounded with &

by Sitaram Chamarty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 19, 2009 at 6:08 AM, Chet Ramey <chet.ramey@...> wrote:

> Sitaram Chamarty wrote:
>> Hello,
>>
>> When the previous command was backgrounded (say "gvim
>> filename.c &") and then you try some other command using
>> Alt-., it expands to "&" and not "filename.c".
>>
>> Is this considered a bug?  Or correct behaviour that just
>> happens to be not useful in this specific case?
>
> M-. uses the last word from the previous line.  If that happens to
> be `&', that's what it uses.

ok thanks; I suspected as much (that this was working as intended, and
the situation I brought up was an edge case) but appreciate the
confirmation.



Re: "alt-period" (alt-.) when previous command was backgrounded with &

by Bob Proulx :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sitaram Chamarty wrote:

> Chet Ramey wrote:
> > Sitaram Chamarty wrote:
> >> When the previous command was backgrounded (say "gvim
> >> filename.c &") and then you try some other command using
> >> Alt-., it expands to "&" and not "filename.c".
> >>
> >> Is this considered a bug?  Or correct behaviour that just
> >> happens to be not useful in this specific case?
> >
> > M-. uses the last word from the previous line.  If that happens to
> > be `&', that's what it uses.
>
> ok thanks; I suspected as much (that this was working as intended, and
> the situation I brought up was an edge case) but appreciate the
> confirmation.

Certainly yank-last-arg (M-.,M-_) is useful but don't forget about
yank-nth-arg (M-C-y) which yanks the first argument.  Most of the time
that you are doing something like 'edit filename.c &' then you can use
the still quite convenient M-C-y to paste in the filename as the first
argument to the next command.

Bob



Re: "alt-period" (alt-.) when previous command was backgrounded with &

by Sitaram Chamarty :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Oct 20, 2009 at 2:22 AM, Bob Proulx <bob@...> wrote:
> Certainly yank-last-arg (M-.,M-_) is useful but don't forget about
> yank-nth-arg (M-C-y) which yanks the first argument.  Most of the time
> that you are doing something like 'edit filename.c &' then you can use
> the still quite convenient M-C-y to paste in the filename as the first
> argument to the next command.

Cool thanks!  Tantalisingly, it also says "nth" arg, but I can't
figure out how to give it that "n" (when n != 1).  However, it seems I
can do this with M-. -- I just prefix an M-1 before the M-. (thought
my terminal does get messed up; probably because I have a very complex
bash prompt with colors and all...)



Re: "alt-period" (alt-.) when previous command was backgrounded with &

by Bob Proulx :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sitaram Chamarty wrote:
> Cool thanks!  Tantalisingly, it also says "nth" arg, but I can't
> figure out how to give it that "n" (when n != 1). However, it seems
> I can do this with M-. -- I just prefix an M-1 before the
> M-. (thought my terminal does get messed up; probably because I have
> a very complex bash prompt with colors and all...)

You have probably tripped into bash FAQ number E3.  Easy to fix.

Bob