From 050db8b7cd5edfa3be4f984a6057738871b81e0e Mon Sep 17 00:00:00 2001 From: Christopher Apple Date: Tue, 26 Nov 2019 09:35:33 +0100 Subject: [PATCH] Better way to do spaces in filenames Former-commit-id: 803cb4fd2dcc972ded146c17d992395a982b82ee --- forgit.plugin.fish | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/forgit.plugin.fish b/forgit.plugin.fish index 9a707b8..51f8357 100755 --- a/forgit.plugin.fish +++ b/forgit.plugin.fish @@ -63,10 +63,7 @@ function forgit::diff set repo "(git rev-parse --show-toplevel)" set target "\(echo {} | sed 's/.*] //')" - # TODO: remove pipe from front of forget_pager set cmd "git diff --color=always $commit -- $repo/$target | $forgit_pager" - echo $cmd - exit set opts " $FORGIT_FZF_DEFAULT_OPTS +m -0 --preview=\"$cmd\" --bind=\"enter:execute($cmd |env LESS='-R' less)\" @@ -94,12 +91,15 @@ function forgit::add " set files (git -c color.status=always -c status.relativePaths=true status --short | grep -F -e "$changed" -e "$unmerged" -e "$untracked" | - awk '{printf "[%10s] ", $1; $1=""; print $0}' | - env FZF_DEFAULT_OPTS="$opts" fzf | cut -d] -f2 | + sed 's/^\(..[^[:space:]]*\)[[:space:]]\+\(.*\)\$/[\1] \2/' | + env FZF_DEFAULT_OPTS="$opts" fzf | cut -d " " -f 2- | sed 's/.* -> //') # for rename case if test -n "$files" - echo $files | tr ' ' '\n' |xargs -I{} git add {} && git status --short && return + for file in $files + echo $file | tr "\n" "\0" | xargs -I{} -0 git add {} && git status --short && return + end + return end echo 'Nothing to add.' end