From c68498fc7929c2e2791132d2ff876679034bb5a9 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sat, 23 Dec 2017 19:39:10 -0800 Subject: [PATCH] `string trim` appears to be a hair faster than regex. --- fish_prompt.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index eb14e65..0cfae19 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -723,7 +723,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st return end - set -l project_pwd (command git rev-parse --show-prefix ^/dev/null | string replace -r '/$' '') + set -l project_pwd (command git rev-parse --show-prefix ^/dev/null | string trim --right --chars=/) set -l work_dir (command git rev-parse --show-toplevel ^/dev/null) # only show work dir if it's a parent… @@ -765,7 +765,7 @@ function __bobthefish_prompt_git -S -a current_dir -d 'Display the actual git st set project_pwd $PWD string match "$current_dir*" $project_pwd >/dev/null and set project_pwd (string sub -s (math 1 + (string length $current_dir)) $project_pwd) - set project_pwd (string replace -r '^/' '' $project_pwd) + set project_pwd (string trim --left --chars=/ -- $project_pwd) if [ "$project_pwd" ] set -l colors $__color_path