From 9ebd457279406093bbb92939dce8e110ca309142 Mon Sep 17 00:00:00 2001 From: kevadesu Date: Sat, 18 Jan 2025 20:03:06 +0100 Subject: [PATCH] Add environment variable "GIR_FORCEALL" Annoyed whenever you need to remove something but Git needs you to force it? Now you can run Gir with the environment variable GIR_FORCEALL Set it to either 1, TRUE or true and it will know to force all git operations. --- main.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.sh b/main.sh index aa78333..87ccb9d 100755 --- a/main.sh +++ b/main.sh @@ -32,7 +32,14 @@ function gir.main() { git add $(ls | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...") ;; "Remove files from commit") - git rm $(ls | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...") + case $GIR_FORCEALL in + 1|TRUE|true) + git rm $(ls | gum filter --selected-indicator.foreground="#d20f39" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Remove files" --prompt="| " --indicator="> " --selected-prefix "REMOVE " --unselected-prefix " KEEP " --placeholder "Press TAB to select, Enter to confirm...") -f + ;; + *) + git rm $(ls | gum filter --selected-indicator.foreground="#d20f39" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Remove files" --prompt="| " --indicator="> " --selected-prefix "REMOVE " --unselected-prefix " KEEP " --placeholder "Press TAB to select, Enter to confirm...") + ;; + esac ;; "Commit") git commit -m "$(gum input --cursor.foreground="#fe640b" --width 50 --placeholder "Summary of changes")" \ @@ -48,7 +55,7 @@ function gir.main() { git stash ;; "Switch branch") - git checkout $(git branch | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --header "Select hash to undo" --prompt="| " --indicator="> " | sed 's/* //g' | sed 's/ //g') + git checkout $(git branch | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --header "Select branch to switch to" --prompt="| " --indicator="> " | sed 's/* //g' | sed 's/ //g') ;; "(Re)initialise repository") git init @@ -104,7 +111,7 @@ function gir.wrongbranch() { } function gir.undocommit() { - SEL_HASH=$(git log --oneline | gum filter | cut -d' ' -f1) + SEL_HASH=$(git log --oneline | gum filter --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --no-limit --header "Select hash to undo" --prompt="| " --indicator="> " | cut -d' ' -f1) git revert $SEL_HASH }