-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fish/git_status): handle home printing /var
- Loading branch information
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
36 changes: 18 additions & 18 deletions
36
home/private_dot_config/fish/custom_functions.d/git_status.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |