From 2ed0dad834cc52f888e5474c79baae9a8889a0d7 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Sat, 4 Feb 2023 18:47:42 -0500 Subject: [PATCH] [F] Fix repeated sourcing on update --- scripts/includes/git.sh | 16 ---------- scripts/includes/git.zsh | 63 ++++++++++++++++++++++++++++++++++++++++ scripts/zshrc.sh | 51 ++------------------------------ 3 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 scripts/includes/git.sh create mode 100644 scripts/includes/git.zsh diff --git a/scripts/includes/git.sh b/scripts/includes/git.sh deleted file mode 100644 index f756c6f..0000000 --- a/scripts/includes/git.sh +++ /dev/null @@ -1,16 +0,0 @@ -# Git commit wrapper -commit() { - msg="$@" - git commit -m "$msg" -} - -commitall() { - git add . - commit "$@" -} -alias commita="commitall" - -compush() { - commitall "$@" - git push -} diff --git a/scripts/includes/git.zsh b/scripts/includes/git.zsh new file mode 100644 index 0000000..9ff86a2 --- /dev/null +++ b/scripts/includes/git.zsh @@ -0,0 +1,63 @@ +# Git commit wrapper +commit() { + msg="$@" + git commit -m "$msg" +} + +commitall() { + git add . + commit "$@" +} +alias commita="commitall" + +compush() { + commitall "$@" + git push +} + +# Git identity +git-ida() { + # Zsh only + TMP_ARR=("${(@f)$(git-id-list get "$1")}") + git-id "${TMP_ARR[1]}" "${TMP_ARR[2]}" +} +git-id() { + export GIT_USER="$1" + export GIT_EMAIL="$2" + git-id-prompt +} +git-id-prompt() { + if [[ -z "$GIT_USER" ]] && [[ -z "$GIT_EMAIL" ]]; then + prompt-reset + else + prompt-set 30 "&cGit ID: $GIT_USER | $GIT_EMAIL " + prompt-update + fi +} +git-id-prompt +[[ -z $GIT_BIN ]] && GIT_BIN=$(which git) +git() { + if [[ -z "$GIT_USER" ]]; then + $GIT_BIN "$@" + else + $GIT_BIN -c "user.name=$GIT_USER" -c "user.email=$GIT_EMAIL" -c "commit.gpgsign=false" "$@" + fi +} + +# Git environment +git-env() { + git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag ) + for i in "${git_commands[@]}" + do + alias "$i"="git $i" + done + alias 'grm'='git rm' + alias 'gmv'='git mv' +} +git-unenv() { + git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag grm gmv ) + for i in "${git_commands[@]}" + do + unalias "$i" + done +} diff --git a/scripts/zshrc.sh b/scripts/zshrc.sh index c77a7b2..f8622c2 100755 --- a/scripts/zshrc.sh +++ b/scripts/zshrc.sh @@ -108,7 +108,7 @@ alias jctl="sudo journalctl" alias ufw="sudo ufw" # Gradle with auto environment detection -GRADLE="$(which gradle)" +[[ -z $GRADLE ]] && GRADLE="$(which gradle)" gradle() { [[ -f "./gradlew" ]] && ./gradlew "$@" || $GRADLE "$@" } @@ -227,55 +227,8 @@ setproxy() { prompt-update } -# Git identity -git-ida() { - # Zsh only - TMP_ARR=("${(@f)$(git-id-list get "$1")}") - git-id "${TMP_ARR[1]}" "${TMP_ARR[2]}" -} -git-id() { - export GIT_USER="$1" - export GIT_EMAIL="$2" - git-id-prompt -} -git-id-prompt() { - if [[ -z "$GIT_USER" ]] && [[ -z "$GIT_EMAIL" ]]; then - prompt-reset - else - prompt-set 30 "&cGit ID: $GIT_USER | $GIT_EMAIL " - prompt-update - fi -} -git-id-prompt -GIT_BIN=$(which git) -git() { - if [[ -z "$GIT_USER" ]]; then - $GIT_BIN "$@" - else - $GIT_BIN -c "user.name=$GIT_USER" -c "user.email=$GIT_EMAIL" -c "commit.gpgsign=false" "$@" - fi -} - -# Git environment -git-env() { - git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag ) - for i in "${git_commands[@]}" - do - alias "$i"="git $i" - done - alias 'grm'='git rm' - alias 'gmv'='git mv' -} -git-unenv() { - git_commands=( add bisect branch checkout clone commit diff fetch grep init log merge pull push rebase reset restore show status tag grm gmv ) - for i in "${git_commands[@]}" - do - unalias "$i" - done -} - # SSH Patch -SSH_BIN=$(which ssh) +[[ -z $SSH_BIN ]] && SSH_BIN=$(which ssh) ssh() { if [[ "$TERM" == 'xterm-kitty' ]]; then env TERM=xterm-256color "$SSH_BIN" "$@"