From a9c8b755992703f5499e2da91d50579cbd65046d Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Sun, 21 Sep 2014 19:54:42 -0700 Subject: [PATCH] Tweak git completion for aliases/stashes Use the new `read -z` flag to complete git aliases better. This approach won't break if an alias contains a newline. Also fix stash completion, which was broken on BSD sed. --- share/completions/git.fish | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index 5fda2935c..ae2a6a570 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -84,11 +84,21 @@ function __fish_git_stash_not_using_subcommand end function __fish_git_complete_stashes - command git stash list --format=format:"%gd:%gs" | sed 's/:/\t/' + set -l IFS ':' + command git stash list --format=%gd:%gs | while read -l name desc + echo $name\t$desc + end end function __fish_git_aliases - command git config --get-regexp '^alias\.' | sed -n "s/^alias\.\([^ ]*\).*/\1/p" + set -l IFS \n + command git config -z --get-regexp '^alias\.' | while read -lz key value + begin + set -l IFS "." + echo -n $key | read -l _ name + echo $name + end + end end function __fish_git_custom_commands