From 4ede6e0371818683c9c925f1625517a3ca39c7be Mon Sep 17 00:00:00 2001
From: Kostis Anagnostopoulos <ankostis@gmail.com>
Date: Tue, 17 May 2022 23:14:19 +0300
Subject: [PATCH] FEAT(setup) GITcompletions for bash ALIASES; >

+ feat: more aliases:
  + commit
  + reset
  + remote
---
 setup-account.sh | 77 +++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 66 insertions(+), 11 deletions(-)

diff --git a/setup-account.sh b/setup-account.sh
index db809a2..0a4d9ce 100755
--- a/setup-account.sh
+++ b/setup-account.sh
@@ -165,16 +165,22 @@ EOF
 
 function upd20_bash_aliases {
     local check_file="$HOME/.bash_aliases"
-    if _grep_before_update "$check_file" "alias lg="; then
+    if _grep_before_update "$check_file" "## UDS: GIT ALIASES"; then
         cat >> "$check_file" <<- "EOF"
 
-## GIT ALIASES
+####
+## UDS: GIT ALIASES
 alias lg='git lg'
 alias lgg='git lgg'
 alias log='git log'
 alias status='git status'
 alias show='git show'
-alias log='git log'
+alias cm='git commit'
+alias chk='git checkout'
+alias ch-='git checkout -'
+alias rs='git reset'
+alias rss='git reset --soft'
+alias rsh='git reset --hard'
 alias rb='git rebase'
 alias rbi='git rebase -i'
 alias rba='git rebase --abort'
@@ -182,8 +188,52 @@ alias rbc='git rebase --continue'
 alias chrp='git cherry-pick'
 alias chrpa='git cherry-pick --abort'
 alias chrpc='git cherry-pick --continue'
-alias chk='git checkout'
-alias ch-='git checkout -'
+alias rem='git remote'
+alias remv='git remote --verbose'
+alias rema='git remote add'
+alias remu='git remote set-url'
+alias remr='git remote rename'
+
+_git_completion_cmd="complete -o bashdefault -o default -o nospace -F"
+
+function __git_wrap__git_log { __git_func_wrap _git_log; }
+function __git_wrap__git_status { __git_func_wrap _git_status; }
+function __git_wrap__git_show { __git_func_wrap _git_show; }
+function __git_wrap__git_commit { __git_func_wrap _git_commit; }
+function __git_wrap__git_checkout { __git_func_wrap _git_checkout; }
+function __git_wrap__git_reset { __git_func_wrap _git_reset; }
+function __git_wrap__git_rebase { __git_func_wrap _git_rebase; }
+function __git_wrap__git_cherry_pick { __git_func_wrap _git_cherry_pick; }
+function __git_wrap__git_remote { __git_func_wrap _git_remote; }
+
+$_git_completion_cmd __git_wrap__git_log        log
+$_git_completion_cmd __git_wrap__git_log        lg
+$_git_completion_cmd __git_wrap__git_log        lgg
+
+$_git_completion_cmd __git_wrap__git_show       show
+
+$_git_completion_cmd __git_wrap__git_reset      rs
+$_git_completion_cmd __git_wrap__git_reset      rss
+$_git_completion_cmd __git_wrap__git_reset      rsh
+
+$_git_completion_cmd __git_wrap__git_checkout   ch
+$_git_completion_cmd __git_wrap__git_checkout   ch-
+
+$_git_completion_cmd __git_wrap__git_rebase     rb
+$_git_completion_cmd __git_wrap__git_rebase     rbi
+$_git_completion_cmd __git_wrap__git_rebase     rbc
+$_git_completion_cmd __git_wrap__git_rebase     rba
+
+$_git_completion_cmd __git_wrap__git_cherry_pick        chrp
+$_git_completion_cmd __git_wrap__git_cherry_pick        chrpc
+$_git_completion_cmd __git_wrap__git_cherry_pick        chrpa
+
+$_git_completion_cmd __git_wrap__git_cherry_remote      rem
+$_git_completion_cmd __git_wrap__git_cherry_remote      remv
+$_git_completion_cmd __git_wrap__git_cherry_remote      rema
+$_git_completion_cmd __git_wrap__git_cherry_remote      remu
+$_git_completion_cmd __git_wrap__git_cherry_remote      remr
+
 EOF
         echo "UPDATED"
     fi
@@ -217,10 +267,12 @@ function upd20_git_aliases {
 
         git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
         git config --global alias.lgg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"
-        git config --global alias.log   'log'
-        git config --global alias.status 'status'
-        git config --global alias.show  'show'
-        git config --global alias.log   'log'
+        git config --global alias.cm    'commit'
+        git config --global alias.chk   'checkout'
+        git config --global alias.ch-   'checkout -'
+        git config --global alias.rs    'reset'
+        git config --global alias.rss   'reset --soft'
+        git config --global alias.rsh   'reset --hard'
         git config --global alias.rb    'rebase'
         git config --global alias.rbi   'rebase -i'
         git config --global alias.rba   'rebase --abort'
@@ -228,8 +280,11 @@ function upd20_git_aliases {
         git config --global alias.chrp  'cherry-pick'
         git config --global alias.chrpa 'cherry-pick --abort'
         git config --global alias.chrpc 'cherry-pick --continue'
-        git config --global alias.chk   'checkout'
-        git config --global alias.ch-   'checkout -'
+        git config --global alias.rem   'remote'
+        git config --global alias.remv  'remote --verbose'
+        git config --global alias.rema  'remote add'
+        git config --global alias.remu  'remote set-url'
+        git config --global alias.remr  'remote rename'
 
         _log "UPDATED"
     fi
-- 
GitLab