bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using alias to commands disables its completion


From: Eric Blake
Subject: Re: Using alias to commands disables its completion
Date: Thu, 24 Mar 2011 13:54:01 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.9

On 03/24/2011 10:54 AM, Gustavo Serra Scalet wrote:
> Description:
>     When an alias is supplied to a command (e.g: alias c="cd") the
>     complete doesn't complete like it used when using the original text,
> without
>     using alias (e.g $ c <TAB><TAB> # returns all files, not just
> directories)
> 
>     It doesn't seem to have any technical issue problem to make the
> detection of
>     completion also by using alias (as when <ENTER> is hit the alias are
> also
>     interpreted).

The lame answer:

But you can already do this yourself!  Write a shell function around
alias, that calls both 'command alias' to do the real work, as well as
'complete -p' on the first word of new expansion then 'complete ...' on
the new alias name, so that you copy any completion properties tied to
the old name over to the new name.

As long as you define your programmable completions before your aliases
as part of your ~/.bashrc startup sequence, then this works.

Even better, submit that as an enhancement request to the
bash-completion project to have bash-completion provide that wrapper
around alias provided automatically as part of starting up bash-completion.

The answer you sort of wanted:

Yes, it would be nice to patch to bash's completion routines to add an
opt-in ability to check for programmed completion associated with
whatever the alias expanded to, and use that when there is no completion
already associated with the aliased name.  But someone has to write such
a patch.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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