W dniu 11.10.2016 o 13:51, SZEDER Gábor pisze: > Quoting Duy Nguyen <pclouds@xxxxxxxxx>: >> On Fri, Oct 7, 2016 at 10:55 PM, Jakub Narębski <jnareb@xxxxxxxxx> wrote: >>> W dniu 07.10.2016 o 16:19, Johannes Schindelin pisze: >>>> On Fri, 7 Oct 2016, Jakub Narębski wrote: >>> >>>>> Note that we would have to teach git completion about new syntax; >>>>> or new configuration variable if we go that route. >>>> >>>> Why would we? Git's completion does not expand aliases, it only completes >>>> the aliases' names, not their values. >>> >>> Because Git completion finds out which _options_ and _arguments_ >>> to complete for an alias based on its expansion. >>> >>> Yes, this is nice bit of trickery... >> >> It's c63437c (bash: improve aliased command recognition - 2010-02-23) >> isn't it? This may favor j6t's approach [1] because retrieving alias >> attributes is much easier. >> >> [1] https://public-inbox.org/git/20161006190720.4ecf3ptl6msztoya@xxxxxxxxxxxxxxxxxxxxx/T/#mb1d7b8f31d595b05105b8ea2137756761e13dbf4 >> -- >> Duy > > The completion script is concerned in three ways: > > 1. it has to get the names of all aliases, to offer them along with > git commands for 'git <TAB>' or 'git help <TAB>', > > 2. it has to get the command executed in place of the alias, and > > 3. strip everything that can't be a git command, so it can offer the > right options for the aliased command. There is also a possibility to tell the completion script which git command to use for option completion via some trickery, even if the first git command of many used in script is not right (e.g. when "$@" is passed somewhere in the middle). I don't remember exact details, but let's look at source: # If you use complex aliases of form '!f() { ... }; f', you can use the null # command ':' as the first command in the function body to declare the desired # completion style. For example '!f() { : git commit ; ... }; f' will # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". Very nice. > > The '!!' syntax is the easiest, I think it will just work even with > the current completion code, no changes necessary. > > The '(nocd)' form is still easy, we only have to add this '(nocd)' to > that list of stripped words for (3), but no further changes necessary > for (1) and (2). Shouldn't the '!' vs '!!' / '(nocd)!' affect pathname completion? Or do tab completion in subdir offer wrong completion of filenames for aliases? Best, -- Jakub Narębski