From: SZEDER Gábor Date: Fri, 29 Jan 2010 20:00:33 GMT Subject: Re: [PATCH] bash: support user-supplied completion scripts for user's git commands Message-ID: <20100129200033.GA32636@neumann> In-Reply-To: <20100129191326.GD22101@spearce.org> Hi Shawn, On Fri, Jan 29, 2010 at 11:13:26AM -0800, Shawn O. Pearce wrote: > SZEDER G?bor wrote: > > How about something like this for subcommands (not aliases)? It's a > > good code size reduction anyway. > > Hmm, I like this. I just didn't know how to implement it... :-) > > Acked-by: Shawn O. Pearce > > > + local completion_func="_git_${command//-/_}" > > + declare -F $completion_func >/dev/null && $completion_func > > Yay for knowing bash. :-) Heh. I've found out about this 'declare -F' thing about two hours ago (; However. I thought this should actually "Just Work" for aliases, too. e.g. Junio could use the following completion function to get 'git log's options for his lgm alias: _git_lgm () { _git_log } Unfortunately, it doesn't work at all. In _git() first we have 'lgm' in $command, which is ok, but then comes this alias handling thing local expansion=$(__git_aliased_command "$command") [ "$expansion" ] && command="$expansion" which writes '!sh' into $command, and that doesn't look quite right for me, although I admit that I can't seem to figure out how this __git_aliased_command() is supposed to work (so much about knowing bash ;). Any insight? Best, Gábor