Skip to content

Commit

Permalink
fix(fish/git_status): handle home printing /var
Browse files Browse the repository at this point in the history
  • Loading branch information
scottames committed Jan 27, 2024
1 parent 6c032ab commit 97cd74a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions home/private_dot_config/fish/custom_functions.d/git_status.fish
Original file line number Diff line number Diff line change
@@ -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 '[email protected]:' '' \
| 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

0 comments on commit 97cd74a

Please sign in to comment.