From 896a960a034eabc0e6f103ae54f0686f24567cee Mon Sep 17 00:00:00 2001 From: Christopher Apple Date: Sat, 13 Jun 2020 10:59:47 -0700 Subject: [PATCH] fixed gcf, and a bunch of other things. Added git status before most returns --- forgit.plugin.fish | 21 ++++++++++++++------- forgit.plugin.zsh | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/forgit.plugin.fish b/forgit.plugin.fish index 9c4516a..3429525 100755 --- a/forgit.plugin.fish +++ b/forgit.plugin.fish @@ -83,7 +83,7 @@ end function forgit::add forgit::inside_work_tree || return 1 # Add files if passed as arguments - count $argv >/dev/null && git add "$argv" && return + count $argv >/dev/null && git add "$argv" && git status --short && return set changed (git config --get-color color.status.changed red) set unmerged (git config --get-color color.status.unmerged red) @@ -119,6 +119,7 @@ function forgit::add for file in $files echo $file | tr '\n' '\0' | xargs -I{} -0 git add {} end + git status --short return end echo 'Nothing to add.' @@ -136,14 +137,16 @@ function forgit::reset::head set files (git diff --cached --name-only --relative | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd") if test -n "$files" for file in $files - echo $file | tr '\n' '\0' |xargs -I{} -0 git reset -q HEAD {} && git status --short && return + echo $file | tr '\n' '\0' |xargs -I{} -0 git reset -q HEAD {} end + git status --short + return end echo 'Nothing to unstage.' end # git checkout-restore selector -function forgit::restore +function forgit::checkout_file forgit::inside_work_tree || return 1 set cmd "git diff --color=always -- {} | $forgit_pager" @@ -156,8 +159,10 @@ function forgit::restore set files (git ls-files --modified "$git_rev_parse" | env FZF_DEFAULT_OPTS="$opts" fzf --preview="$cmd") if test -n "$files" for file in $files - echo $file | tr '\n' '\0' |xargs -I{} -0 git checkout {} && git status --short && return + echo $file | tr '\n' '\0' | xargs -I{} -0 git checkout -q {} end + git status --short + return end echo 'Nothing to restore.' end @@ -188,8 +193,10 @@ function forgit::clean if test -n "$files" for file in $files - echo $file | tr '\n' '\0'|xargs -0 -I{} git clean -xdf {} && return + echo $file | tr '\n' '\0'| xargs -0 -I{} git clean -xdf {} end + git status --short + return end echo 'Nothing to clean.' end @@ -319,9 +326,9 @@ if test -z "$FORGIT_NO_ALIASES" end if test -n "$forgit_restore" - alias $forgit_restore 'forgit::restore' + alias $forgit_restore 'forgit::checkout_file' else - alias gcf 'forgit::restore' + alias gcf 'forgit::checkout_file' end if test -n "$forgit_clean" diff --git a/forgit.plugin.zsh b/forgit.plugin.zsh index 252c7ae..16d9dd5 100755 --- a/forgit.plugin.zsh +++ b/forgit.plugin.zsh @@ -54,7 +54,7 @@ forgit::diff() { forgit::add() { forgit::inside_work_tree || return 1 # Add files if passed as arguments - [[ $# -ne 0 ]] && git add "$@" && return + [[ $# -ne 0 ]] && git add "$@" && git status -su && return local changed unmerged untracked files opts preview extract changed=$(git config --get-color color.status.changed red) @@ -142,7 +142,7 @@ forgit::clean() { " # Note: Postfix '/' in directory path should be removed. Otherwise the directory itself will not be removed. files=$(git clean -xdfn "$@"| sed 's/^Would remove //' | FZF_DEFAULT_OPTS="$opts" fzf |sed 's#/$##') - [[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git clean -xdf '%' && return + [[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% git clean -xdf '%' && git status --short && return echo 'Nothing to clean.' }