Skip to content

Commit

Permalink
Merge pull request #141 from szczys/szczys/add-clear-options
Browse files Browse the repository at this point in the history
✨ add setting for clear in git aliases
  • Loading branch information
diogocavilha authored Sep 27, 2023
2 parents ecb6fea + 1604c8e commit 190bd5e
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

> Any trouble, please visit the [troubleshooting page](https://github.com/diogocavilha/fancy-git/blob/master/TROUBLESHOOTING.md)
## v7.6.0
- Add `fancygit --enable-git-clear` command to clear terminal on some Git aliases (ga, gaa, gck, gd, gs).
- Add `fancygit --disable-git-clear` command to prevent clearing terminal on some Git aliases (ga, gaa, gck, gd, gs).

## v7.5.5
- Add more icon overrides using the `FANCYGIT_ICON_GIT_REPO` and `FANCYGIT_ICON_VENV` environment variables.

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ Type `fancygit -h` to see all available feature switchers on **"FEATURE SWITCHER
| fancygit --unset-user-name | Restore the user name to default.
| fancygit --set-host-name {name} | Set the host name.
| fancygit --unset-host-name | Restore the host name to default.
| fancygit --enable-git-clear | Clear the terminal as part of some git aliases
| fancygit --disable-git-clear | Do not clear the terminal with any git aliases
| fancygit --separator-default | Change the separator to default style.
| fancygit --separator-blocks | Change the separator to blocks style.
| fancygit --separator-blocks-tiny | Change the separator to blocks-tiny style.
Expand Down
7 changes: 6 additions & 1 deletion alias_functions/ga.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#
# git add

. ~/.fancy-git/modules/settings-manager.sh
git_use_clear=$(fancygit_config_get "git_use_clear" "true")

git add "$*" && \
clear && \
if [ "$git_use_clear" = "true" ]; then \
clear; \
fi && \
git status
7 changes: 6 additions & 1 deletion alias_functions/gaa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#
# git add --all

. ~/.fancy-git/modules/settings-manager.sh
git_use_clear=$(fancygit_config_get "git_use_clear" "true")

git add --all && \
clear && \
if [ "$git_use_clear" = "true" ]; then \
clear; \
fi && \
git status
7 changes: 6 additions & 1 deletion alias_functions/gck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#
# git checkout --

. ~/.fancy-git/modules/settings-manager.sh
git_use_clear=$(fancygit_config_get "git_use_clear" "true")

git checkout -- "$*" && \
clear && \
if [ "$git_use_clear" = "true" ]; then \
clear; \
fi && \
git status
15 changes: 12 additions & 3 deletions alias_functions/gd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@
#
# git diff

. ~/.fancy-git/modules/settings-manager.sh
git_use_clear=$(fancygit_config_get "git_use_clear" "true")

clear_if_enabled () {
if [ "$git_use_clear" = "true" ]; then
clear
fi
}

# It's more like a return command. This is a Mac OS issue.
fg_return() {
exit
}

clear
clear_if_enabled

if [ "$1" = "" ]; then
git diff
Expand All @@ -24,7 +33,7 @@ read -rp " Add this file to commit? [y/N]: " r

if [ "$r" = "y" ]; then
git add "$1"
clear
clear_if_enabled
git status
fg_return
fi
Expand All @@ -35,5 +44,5 @@ if [ "$r" = "y" ]; then
git checkout "$1"
fi

clear
clear_if_enabled
git status
14 changes: 14 additions & 0 deletions alias_functions/gs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
#
# Author: Mike Szczys <[email protected]>
# Date: 06.02.2023
#
# git status

. ~/.fancy-git/modules/settings-manager.sh
git_use_clear=$(fancygit_config_get "git_use_clear" "true")

if [ "$git_use_clear" = "true" ]; then \
clear; \
fi && \
git status
2 changes: 1 addition & 1 deletion aliases
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
alias fancygit="sh ~/.fancy-git/commands-handler.sh $1"
alias gs="clear && git status"
alias gs="sh ~/.fancy-git/alias_functions/gs.sh"
alias ga="sh ~/.fancy-git/alias_functions/ga.sh"
alias gap="git add -p"
alias gaa="sh ~/.fancy-git/alias_functions/gaa.sh"
Expand Down
2 changes: 2 additions & 0 deletions commands-handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ case "$1" in
"--disable-host-name") fancygit_config_save "show_host_prompt" "false";;
"--enable-user-symbol") fancygit_config_save "show_user_symbol_prompt" "true";;
"--disable-user-symbol") fancygit_config_save "show_user_symbol_prompt" "false";;
"--enable-git-clear") fancygit_config_save "git_use_clear" "true";;
"--disable-git-clear") fancygit_config_save "git_use_clear" "false";;

# Set Name and Host.
"--set-user-name") fancygit_config_save "user_name" "$2";;
Expand Down
2 changes: 2 additions & 0 deletions fancygit-completion
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ _fancygit() {
--disable-host-name \
--enable-user-symbol \
--disable-user-symbol \
--enable-git-clear \
--disable-git-clear \
--set-user-name \
--unset-user-name \
--set-host-name \
Expand Down
2 changes: 2 additions & 0 deletions help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ FEATURE SWITCHER COMMANDS:
fancygit --disable-bold-prompt Show regular prompt font.
fancygit --enable-host-name Show host name. (It works for human theme only)
fancygit --disable-host-name Hide host name. (It works for human theme only)
fancygit --enable-git-clear Clear the terminal as part of some git aliases
fancygit --disable-git-clear Do not clear the terminal with any git aliases
THEME COMMANDS:
fancygit --theme-default Change prompt to the default theme.
Expand Down
2 changes: 1 addition & 1 deletion version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Author: Diogo Alexsander Cavilha <[email protected]>
# Date: 11.17.2017

export FANCYGIT_VERSION="7.5.5"
export FANCYGIT_VERSION="7.6.0"

0 comments on commit 190bd5e

Please sign in to comment.