From 6021ad31941203dafc2abd643a98fb549b620c6a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Tue, 2 Aug 2016 16:12:59 -0400 Subject: [PATCH] Augments functions to achieve more expected behavior --- .git_functions.sh | 2 +- .misc_functions.sh | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.git_functions.sh b/.git_functions.sh index 1ed0fc0d8..e22294c37 100644 --- a/.git_functions.sh +++ b/.git_functions.sh @@ -51,7 +51,7 @@ function wgcheckout { # wgcheckout combined with a fuzzy search function wgfcheckout { - branchname=$(git branch | fzf) + branchname=$(trim $(git branch | fzf)) [ ! -z "$branchname" ] && wgcheckout "$branchname" || return } diff --git a/.misc_functions.sh b/.misc_functions.sh index d8be9ba9e..a0d36e613 100644 --- a/.misc_functions.sh +++ b/.misc_functions.sh @@ -22,7 +22,14 @@ function wfd { # pushd into a directory on your dirs stack function wpushd { - dir=$(dirs | tr ' ' '\n' | fzf | dirname) && pushd "$dir" + dir="$(dirs | tr ' ' '\n' | fzf)" && pushd "$dir" } +# trims leading and trailing whitespace +function trim { + input="$1" + + echo "${input//[[:blank:]]/}" +} +