From 9741abee35408ddc4ef1a9e9359b9360dd1151fb Mon Sep 17 00:00:00 2001 From: desktop Date: Thu, 26 Oct 2023 22:12:08 +0300 Subject: [PATCH] bash : add autocomplete for git & repurpose gu. --- .README.md | 3 +- document/linux/config/bash/module/git.sh | 38 +++++++++++++++++------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.README.md b/.README.md index ff9784c..0d61dde 100644 --- a/.README.md +++ b/.README.md @@ -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. diff --git a/document/linux/config/bash/module/git.sh b/document/linux/config/bash/module/git.sh index a0715e6..c20343c 100644 --- a/document/linux/config/bash/module/git.sh +++ b/document/linux/config/bash/module/git.sh @@ -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