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:]]/}" +} +