bash : add autocomplete for git & repurpose gu.

This commit is contained in:
Dmitry Voronin 2023-10-26 22:12:08 +03:00
parent af6416d32b
commit 9741abee35
2 changed files with 28 additions and 13 deletions

View file

@ -478,8 +478,7 @@ Command|Description
`gp`|Git patch (apply).
`ga`|Git add with preview.
`gr [COUNT]`|Git rebase. 2 last commits by default. 0 means from root.
`gu [NAME] [EMAIL]`|Configure git user (project).
`guv`, `guf`|My own user combos for personal and work.
`gu [EMAIL]`|Configure git user as Dmitry Voronin with specified email (project).
## Ls.

View file

@ -46,15 +46,15 @@ gr()
fi
}
# specify git user.
# usage: gu [NAME] [EMAIL]
# specify git user as Dmitry Voronin with provided email.
# usage: gu [EMAIL]
gu()
{
local name="${1}"
local email="${2}"
local name="Dmitry Voronin"
local email="${1}"
if [[ "${name}" = "" || "${email}" = "" ]]; then
echo "usage: gu [NAME] [EMAIL]"
echo "usage: gu [EMAIL]"
return 1
fi
@ -62,10 +62,26 @@ gu()
git config user.email "${email}"
}
# some extra aliases for gu.
alias guv="gu 'Dmitry Voronin' 'account@voronind.com'"
alias guf="gu 'Dmitry Voronin' 'dd.voronin@fsight.ru'"
# autocomplete.
# _completion_loader git
# __git_complete gps _git_push
_completion_loader git
__git_complete gps _git_push
__git_complete gpsf _git_push
__git_complete gpl _git_pull
__git_complete gl _git_log
__git_complete gs _git_status
__git_complete gst _git_stash
__git_complete gd _git_diff
__git_complete gc _git_commit
__git_complete gch _git_checkout
__git_complete gb _git_branch
__git_complete gf _git_fetch
__git_complete gt _git_tag
__git_complete gp _git_apply
__git_complete ga _git_add
_gu()
{
_autocomplete account@voronind.com dd.voronin@fsight.ru
}
complete -F _gu gu