Skip to content

Commit

Permalink
A brand new thing
Browse files Browse the repository at this point in the history
Added init option, enter confirmation, orange accent colour etc.
  • Loading branch information
kevadesu committed Jan 18, 2025
1 parent 915b901 commit bbbf1c5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ With the elements of [Gum](https://github.com/charmbracelet/gum) and [Oh Shit, G

There's not much else to say.......except that the Setup...at least works

This is licensed under the MIT license
To install, grab the latest Setup.sh from [the latest release](https://github.com/Icycoide/Gir/releases/latest) and run it

This is licensed under the MIT license
21 changes: 18 additions & 3 deletions Setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ main() {
case $OPT in
Y|y|Yes|YES|yes)
echo "Ok!"
inma
inma || echo "FAIL | Installation fail"
;;
*)
niam || echo "FAIL | Installation fail"
Expand Down Expand Up @@ -87,8 +87,23 @@ Install Gum through:
}

inma() {
read -p "What directory should Gir be installed to?" INSTALL_PATH
sudo wget -O $INSTALL_PATH/gir https://github.com/Icycoide/Gir/releases/download/v0.1.0/main.sh || echo "FAIL | Either failed download or invalid path or sudo does not exist."
echo "
1: /usr/bin/
2: /usr/local/bin/
Other: Input any path"
read -p "What directory should Gir be installed to? >" INSTALL_PATH
case $INSTALL_PATH in
1)
INSTALL_PATH=/usr/bin
;;
2)
INSTALL_PATH=/usr/local/bin
;;
*)
echo "Ok!"
;;
esac
sudo wget -O $INSTALL_PATH/gir https://github.com/Icycoide/Gir/releases/download/v0.2.0/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."
}

Expand Down
33 changes: 19 additions & 14 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function gir.main() {
clear
git remote -v
MENU_CHOICE=$(gum choose --header="Current directory: $PWD" "Time Machine" "Add addition to last commit" "Edit last commit's message" "Correct an edit to a different branch" "Diff with fancy flag" "Undo commit" "Read file" "Add files to commit" "Commit" "Push changes" "Pull changes" "(Destructive) Reset to remote state" "(Re)initialise repository" "Quit")
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 commit" "Read file" "Add files to commit" "Commit" "Push changes" "Pull changes" "(Destructive) Reset to remote state" "(Re)initialise repository" "Quit")
case $MENU_CHOICE in
"Time Machine")
gir.timemachine
Expand All @@ -24,17 +24,17 @@ function gir.main() {
gir.undocommit
;;
"Read file")
gum pager < $(gum file --height=5)
gum pager < $(gum file --height=5 --selected.foreground="#fab387" --all --cursor.foreground="#fab387" --directory.foreground="#fe640b")
;;
"Add files to commit")
git add $(ls | gum filter --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="#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...")
;;
"Remove files from commit")
git rm $(ls | gum filter --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm...")
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...")
;;
"Commit")
git commit -m "$(gum input --width 50 --placeholder "Summary of changes")" \
-m "$(gum write --width 80 --placeholder "Details of changes")"
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")"
;;
"Push changes")
git push
Expand All @@ -46,7 +46,7 @@ function gir.main() {
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" && gum spin --spinner minidot --title "Resetting repository to remote state..." -- gir.reset || echo "Operation cancelled."
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" && gum spin --spinner minidot --title "Resetting repository to remote state..." -- gir.reset || echo "Operation cancelled."
;;
"Quit")
exit
Expand All @@ -60,20 +60,20 @@ function gir.timemachine() {
git reflog
LINE_COUNT=$(git reflog | wc -l)
MAX_OUT=$(($LINE_COUNT - 1))
INDEX=$(gum input --placeholder "Select the index to reset to...")
INDEX=$(gum input --cursor.foreground="#fab387" --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?" && 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="#fab387" --prompt.foreground="#fab387" && 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" || kill -INT $$
git add $(ls | gum filter --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="#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...")
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" || 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="#fab387" --prompt.foreground="#fab387" || kill -INT $$
git commit --amend
}

Expand All @@ -83,7 +83,7 @@ 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 --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="#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 commit -m
}

Expand All @@ -93,7 +93,9 @@ function gir.undocommit() {
}

function gir.undofile() {
git checkout $(git log --oneline | gum filter | cut -d' ' -f1) -- $(gum file --show-help --all --file --directory --height=5)
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 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")"
}

function gir.reset() {
Expand All @@ -104,3 +106,6 @@ function gir.reset() {
}

gir.main

# --no-limit --header "Add files" --prompt="| " --indicator="> " --selected-prefix "YES " --unselected-prefix " NO " --placeholder "Press TAB to select, Enter to confirm..."
# --no-limit --header "Select hash to undo" --prompt="| " --indicator="> "

0 comments on commit bbbf1c5

Please # to comment.