Pass PowerShell aliases down to posh-git TabExpansion autocomplete function #257
Closed
Description
I have PS aliases for git, defined as such:
function git-branch-delete { git branch -D $args }
Set-Alias gbd git-branch-delete
function git-checkout { git checkout $args }
Set-Alias gco git-checkout
The $args
represents a branch name, which posh-git would typically autocomplete. However, since aliases are not passed down to posh-git, autocompletion doesn't work.
I monkey-patched this functionality myself, using the technique described in this SO answer:
function TabExpansion($line, $lastWord) {
# aliases that have some form of tab autocomplete functionality
# NOTE: ADDED POST-INSTALL BY USER
$line = $line -replace '^gco ', 'git checkout '
$line = $line -replace '^gbd ', 'git branch '
# end aliases
# rest of the function...
}
It'd be super rad if posh-git could somehow retrieve existing PS aliases related to git functionality like this and patch it into posh-git's autocompletion functionality.
I prefer to use PS aliases over git aliases, primarily for brevity - I'm able to do gcm
instead of git co
or similar.