diff --git a/Setup.sh b/Setup.sh index 979ebe0..de05528 100755 --- a/Setup.sh +++ b/Setup.sh @@ -103,7 +103,7 @@ Other: Input any path" echo "Ok!" ;; esac - sudo wget -O $INSTALL_PATH/gir https://github.com/Icycoide/Gir/releases/download/v0.2.3/main.sh || echo "FAIL | Either failed download or invalid path or sudo does not exist." + sudo wget -O $INSTALL_PATH/gir https://github.com/Icycoide/Gir/releases/download/v0.2.4/main.sh || echo "FAIL | Either failed download or invalid path or sudo does not exist." sudo chmod +x $INSTALL_PATH/gir || echo "FAIL | Either insufficient permissions or file does not exist or sudo does not exist." } diff --git a/main.sh b/main.sh index 5ed1541..754fc1d 100755 --- a/main.sh +++ b/main.sh @@ -2,8 +2,7 @@ function gir.main() { clear - git remote -v - MENU_CHOICE=$(gum filter --header.foreground="#fab387" --unselected-prefix.foreground="#fab387" --selected-indicator.foreground="#fab387" --indicator.foreground="#fab387" --match.foreground="#fab387" --prompt="| " --indicator=">" --header="Current directory: $PWD" --placeholder="Option" "Time Machine" "Add addition to last commit" "Edit last commit's message" "Correct an edit to a different branch" "Diff with fancy flag" "Undo file" "Undo commit" "Read file" "Add files to commit" "Remove files from commit" "Commit" "Push changes" "Pull changes" "Stash changes" "(Destructive) Reset to remote state" "(Re)initialise repository" "About" "Quit") + MENU_CHOICE=$(gum filter --header.foreground="#fe640b" --unselected-prefix.foreground="#fe640b" --selected-indicator.foreground="#fe640b" --indicator.foreground="#fe640b" --match.foreground="#fe640b" --prompt="| " --indicator=">" --header="Repository: $PWD ($(git branch | grep "*" | sed 's/* //g'))" --placeholder="Option" "Time Machine" "Add addition to last commit" "Edit last commit's message" "Correct an edit to a different branch" "Diff with fancy flag" "Undo file" "Undo commit" "Read file" "Add files to commit" "Remove files from commit" "Commit" "Push changes" "Pull changes" "Stash changes" "Switch branch" "(Destructive) Reset to remote state" "(Re)initialise repository" "Information about current repo" "About" "Quit") case $MENU_CHOICE in "Time Machine") gir.timemachine @@ -27,17 +26,24 @@ function gir.main() { gir.undocommit ;; "Read file") - gum pager < $(gum file --height=5 --selected.foreground="#fab387" --all --cursor.foreground="#fab387" --directory.foreground="#fe640b") + gum pager < $(gum file --height=5 --selected.foreground="#fe640b" --all --cursor.foreground="#fe640b" --directory.foreground="#fe640b") ;; "Add files to commit") - git add $(ls | gum filter --selected-indicator.foreground="#fab387" --indicator.foreground="#fab387" --match.foreground="#fab387" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...") + 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="#fab387" --indicator.foreground="#fab387" --match.foreground="#fab387" --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="#fab387" --width 50 --placeholder "Summary of changes")" \ - -m "$(gum write --cursor.foreground="#fab387" --width 80 --placeholder "Details of changes")" + git commit -m "$(gum input --cursor.foreground="#fe640b" --width 50 --placeholder "Summary of changes")" \ + -m "$(gum write --cursor.foreground="#fe640b" --width 80 --placeholder "Details of changes")" ;; "Push changes") git push @@ -48,12 +54,20 @@ function gir.main() { "Stash changes") git stash ;; + "Switch branch") + 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 ;; "(Destructive) Reset to remote state") gum confirm "You are about to reset this repository to the remote state, which will delete all untracked files and overwrite everything with whatever is stored remotely. Are you sure?" --affirmative="Yes, reset!" --negative="No, I changed my mind." --prompt.foreground="#d20f39" --selected.background="#d20f39" && gir.reset || echo "Operation cancelled." ;; + "Information about current repo") + git remote -v + echo " Branch | $(git branch | grep "*" | sed 's/* //g')" + echo "Current directory | $PWD" + ;; "About") gir.about ;; @@ -69,20 +83,20 @@ function gir.timemachine() { git reflog LINE_COUNT=$(git reflog | wc -l) MAX_OUT=$(($LINE_COUNT - 1)) - INDEX=$(gum input --cursor.foreground="#fab387" --placeholder "Select the index to reset to...") + INDEX=$(gum input --cursor.foreground="#fe640b" --placeholder "Select the index to reset to...") clear git reflog | grep "HEAD@{$INDEX}" - gum confirm "Selected index is $INDEX. Are you sure you want to time travel back to it?" --selected.background="#fab387" --prompt.foreground="#fab387" && git reset HEAD@{$INDEX} || echo "Operation cancelled." + gum confirm "Selected index is $INDEX. Are you sure you want to time travel back to it?" --selected.background="#fe640b" --prompt.foreground="#fe640b" && git reset HEAD@{$INDEX} || echo "Operation cancelled." } function gir.tecommit() { - gum confirm "Are you sure you want to amend the last commit? It is not recommended to do this with public commits" --selected.background="#fab387" --prompt.foreground="#fab387" || kill -INT $$ - git add $(ls | gum filter --selected-indicator.foreground="#fab387" --indicator.foreground="#fab387" --match.foreground="#fab387" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...") + gum confirm "Are you sure you want to amend the last commit? It is not recommended to do this with public commits" --selected.background="#fe640b" --prompt.foreground="#fe640b" || kill -INT $$ + 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...") git commit --amend --no-edit } function gir.editcommit() { - gum confirm "Are you sure you want to amend the last commit? It is not recommended to do this with public commits" --selected.background="#fab387" --prompt.foreground="#fab387" || kill -INT $$ + gum confirm "Are you sure you want to amend the last commit? It is not recommended to do this with public commits" --selected.background="#fe640b" --prompt.foreground="#fe640b" || kill -INT $$ git commit --amend } @@ -92,17 +106,17 @@ function gir.wrongbranch() { CORRECT_BRANCH=$(gum input --placeholder "Input the name of the correct branch") gum spin --spinner minidot --title "Running git checkout..." -- git checkout $CORRECT_BRANCH git stash pop - git add $(ls | gum filter --selected-indicator.foreground="#fab387" --indicator.foreground="#fab387" --match.foreground="#fab387" --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...") + 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...") git commit -m } 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 } function gir.undofile() { - git checkout $(git log --oneline | gum filter --selected-indicator.foreground="#fab387" --indicator.foreground="#fab387" --match.foreground="#fab387" --no-limit --header "Select hash to undo" --prompt="| " --indicator="> " | cut -d' ' -f1) -- $(gum file --show-help --all --file --directory --height=5 --selected.foreground="#fab387" --cursor.foreground="#fab387" --directory.foreground="#fe640b") + git checkout $(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) -- $(gum file --show-help --all --file --directory --height=5 --selected.foreground="#fe640b" --cursor.foreground="#fe640b" --directory.foreground="#fe640b") git commit -m "$(gum input --width 50 --placeholder "Summary of changes (wow you didnt even have to copy-paste to undo)")" \ -m "$(gum write --width 80 --placeholder "Details of changes")" } @@ -122,11 +136,11 @@ $(git --version) host system kernel: $(uname -sr) learn more about this release at: -https://github.com/Icycoide/Gir/releases/tag/v$GIR_VERSION" +https://github.com/Icycoide/Gir/releases/tag/v0.2.4" } function gir.variables() { - GIR_VERSION=0.2.3 + GIR_VERSION=0.2.4 } gir.variables