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

View file

@ -46,15 +46,15 @@ gr()
fi fi
} }
# specify git user. # specify git user as Dmitry Voronin with provided email.
# usage: gu [NAME] [EMAIL] # usage: gu [EMAIL]
gu() gu()
{ {
local name="${1}" local name="Dmitry Voronin"
local email="${2}" local email="${1}"
if [[ "${name}" = "" || "${email}" = "" ]]; then if [[ "${name}" = "" || "${email}" = "" ]]; then
echo "usage: gu [NAME] [EMAIL]" echo "usage: gu [EMAIL]"
return 1 return 1
fi fi
@ -62,10 +62,26 @@ gu()
git config user.email "${email}" 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. # autocomplete.
# _completion_loader git _completion_loader git
# __git_complete gps _git_push __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