help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Command completion for an alias


From: contact
Subject: Re: [Help-bash] Command completion for an alias
Date: Mon, 01 Jun 2015 12:28:58 +0200
User-agent: Roundcube Webmail/1.1.1

On 2015-05-30 19:01, Eduardo A. Bustamante López wrote:
On Sat, May 30, 2015 at 02:15:45PM +0200, address@hidden wrote:
Hi folks!

My .bashrc defines some aliases like alias gs='git status'. I'd like to enable command completion for aliases so that when the command line is (| is
the cursor):

Bash provides the completion's mechanism, but the actual code that knows how to complete certain commands is external. The most common package providing these
is bash-completion (https://bash-completion.alioth.debian.org/).

There is a fundamental problem with what you request though. Alias are simple
text substitutions that can expand to anything. If you have:

sc=status
alias gs='git "$sc"'

Then, is this new feature that you propose supposed to somehow evaluate the
code and determine that you're completing 'git status'?

That'd be nice but I had something different in mind. Is there a function, let's call it completions, working like this:

completions git status # => returns the completions for "git status |"
completions git branch -d # => returns the completions for "git branch -d |"

Best regards
--
Greg Navis



reply via email to

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