Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
braydie opened this issue Jul 10, 2017 · 5 comments
Open

Comments

@braydie
Copy link

braydie commented Jul 10, 2017

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
Copy link
Owner

dahlbyk commented Jul 10, 2017

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
Copy link
Author

braydie commented Jul 10, 2017

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 #257 -- I've added my aliases in to GitTabExpansion.ps1 which replaces my alias for git checkout for tab completion purposes

@dahlbyk
Copy link
Owner

dahlbyk commented Jul 10, 2017

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
Copy link

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
Copy link

baflo commented Sep 3, 2024

Hi, has there been any work on this since?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants