From 97cd74af1e5ff9b001b073e64cc46c0bef5feb4e Mon Sep 17 00:00:00 2001 From: Scott Ames Date: Sat, 27 Jan 2024 15:27:47 -0800 Subject: [PATCH] fix(fish/git_status): handle home printing /var --- .../fish/custom_functions.d/git_status.fish | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/home/private_dot_config/fish/custom_functions.d/git_status.fish b/home/private_dot_config/fish/custom_functions.d/git_status.fish index 02c6ca27..49558dcc 100644 --- a/home/private_dot_config/fish/custom_functions.d/git_status.fish +++ b/home/private_dot_config/fish/custom_functions.d/git_status.fish @@ -1,38 +1,38 @@ #!/bin/env fish function git_status --description "Git project status" --wraps "git status" - set -l _is_inside_git_repo (git rev-parse --is-inside-work-tree 2>/dev/null) + set -l _is_inside_git_repo (git rev-parse --is-inside-work-tree 2>/dev/null) - if [ $_is_inside_git_repo ] - printf_green_bold "\nšŸŒ³ worktrees\n\n" - git worktree list + if [ $_is_inside_git_repo ] + printf_green_bold "\nšŸŒ³ worktrees\n\n" + git worktree list | string replace $HOME '~' | string replace /var "" - set -l _org "$( dirname ( + set -l _org "$( dirname ( git config --get remote.origin.url \ | string replace 'git@github.com:' '' \ | string replace 'https://github.com/' '' ))" - set -l _proj "$( basename ( + set -l _proj "$( basename ( git config --get remote.origin.url ) | string replace '.git' '' )" - set -l _git_toplevel (git rev-parse --show-toplevel) - set -l _base_pwd + set -l _git_toplevel (git rev-parse --show-toplevel) + set -l _base_pwd - if [ $_proj != "$(basename $_git_toplevel)" ] # worktree sub-dir - set _base_pwd "$(basename $_git_toplevel)" - end + if [ $_proj != "$(basename $_git_toplevel)" ] # worktree sub-dir + set _base_pwd "$(basename $_git_toplevel)" + end - printf "\nšŸ“‚ " - pwd | string replace $HOME/ '' \ - | awk "{ + printf "\nšŸ“‚ " + pwd | string replace $HOME '~' | string replace /var "" \ + | awk "{ sub(\"$_org\", \"$(set_color cyan -o )$_org$( set_color normal)\"); \ sub(\"$_proj\", \"$(set_color magenta -o )$_proj$(set_color normal)\"); \ sub(\"$_base_pwd\", \"$(set_color yellow -o )$_base_pwd$(set_color normal)\"); \ print }" - printf "\n" - # "$(set_color magenta)foo$(set_color cyan)bar$(set_color yellow)bam$(set_color normal)\n" - end + printf "\n" + # "$(set_color magenta)foo$(set_color cyan)bar$(set_color yellow)bam$(set_color normal)\n" + end - git status $argv + git status $argv end