dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.7k stars 801 forks source link

Is it possible to extend tab complete to work for complex git aliases? #477

Open braydie opened 7 years ago

braydie commented 7 years ago

I have a complex git alias that I'd like to have tab completion on to fill branch names. The command is as follows:

mstage = "!git checkout stage && git pull && git reset --hard && git merge $1 --no-commit"

$1 should be a branch name. I'm able to get this to work using git-complete.bash on bit bash on Windows

Is it possible to extend posh-git to handle tab completion for an alias like the above?

dahlbyk commented 7 years ago

I'm able to get this to work using git-complete.bash on bit bash on Windows

Meaning it already works out-of-the-box? Or you had to extend it in some way?

Is it possible to extend posh-git to handle tab completion for an alias like the above?

We could certainly add an extension point, or maybe even teach posh-git to handle basic compound aliases like yours (split on && and look for $1?

braydie commented 7 years ago

Hey @dahlbyk - sorry I meant to say that I got autocomplete working on git bash following these steps. I believe that is a bash only thing, and wouldn't impact PowerShell (I'm guessing though).

I have a workaround at the moment using https://github.com/dahlbyk/posh-git/issues/257 -- I've added my aliases in to GitTabExpansion.ps1 which replaces my alias for git checkout for tab completion purposes

dahlbyk commented 7 years ago

sorry I meant to say that I got autocomplete working on git bash following these steps. I believe that is a bash only thing, and wouldn't impact PowerShell (I'm guessing though).

Correct. posh-git is essentially an incomplete port of that completion (plus other stuff). As far as I can tell, its alias expansion is handled here. It looks like for your alias it's going to offer completion options for git checkout even though the value will actually be used with merge, but there's a way to use the null command : to specify what command's completion should be shown.

I'm certainly open to posh-git being smarter about parsing these Git aliases.

FranklinYu commented 5 years ago

It would be easier to only pick up aliases right? For example I simply alias git.exe to g. This is IMO already an improvement.

baflo commented 2 months ago

Hi, has there been any work on this since?