Bash Version: 4.1
Patch Level: 7
Release Status: release
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).
Repeat-By:
$ alias c="cd"
$ c <TAB><TAB>
# suppose to only show directories, but it shows every file
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 ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
On 24 March 2011 16:54, Eric Blake <ebl...@redhat.com> wrote:
> 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.
>
hum. I took a look at [1] and understood what you said.
Nice idea, but it doesn't work for some compound aliases (ok, I made this
up. But you'll get it):
http://pastebin.com/khyeFGUS
I got what it happend but I don't know how to solve it.
>
> 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.
>
Ok, I'll analyze that betterly. I just got introduced to bash-completion.
Thanks for that.
>
> 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. <http://libvirt.org>
>
That may also be interesting :-)
Have a nice week
references:
[1] http://www.debian-administration.org/articles/316