matchai / spacefish

πŸš€πŸŸ The fish shell prompt for astronauts
https://spacefish.matchai.dev
MIT License
960 stars 78 forks source link

Disable git for some folders/paths #154

Closed hrvoj3e closed 5 years ago

hrvoj3e commented 5 years ago

Feature Request

Add and option to list regex and/or glob patterns to skip git features.

SPACEFISH_GIT_SKIP '^~/code/sshfs/' '*/sshfs/*'

I am new to this theme - don't know if it is compatible with Spaceship.

My current fix

I have mounted projects via sshfs in ~/code/sshfs/client/project/another/stuff/. Command git status --porcelain -b never ends over sshfs (I always kill it after 3-4 minutes).

Setting set -g SPACEFISH_GIT_SHOW false helps a lot. I still get some git info like branches (but no status). But at least I can run ls inside dir with .git over sshfs.

What I have so far. It works for me for now. ~/.config/fish/fish_prompt_git_disable.fish

function fish_prompt_git_disable
    set -l realhome ~
    set -l dir (pwd)
    set -l gitoff n
    set -l check (string match -r '^'$realhome'/code/sshfs' "$dir")
    if test -n "$check"
        set gitoff y
    end
    ## spacefish theme
    if set -q SPACEFISH_VERSION
        if test "$gitoff" = y
            set -g SPACEFISH_GIT_SHOW false
        else
            set -g SPACEFISH_GIT_SHOW true
        end
    end
end

Call my function inside fish_prompt before setting other defaults. ~/.config/fish/fish_prompt.fish

# Store the exit code of the last command
set -g sf_exit_code $status
set -g SPACEFISH_VERSION 2.2.0
...
fish_prompt_git_disable
...
for i in $SPACEFISH_PROMPT_ORDER
    eval __sf_section_$i
end
set_color normal

Maybe I should try with removing git keyword from SPACEFISH_PROMPT_ORDER. Which is better?

Variable SPACEFISH_GIT_STATUS_SHOW can be used instead SPACEFISH_GIT_SHOW when my pull request is accepted #155

matchai commented 5 years ago

Hey @hrvoj3e!

I really like the idea of having directories that would be skipped in showing the git section, however, this feature would first need to be accepted into the spaceship project to avoid having diverging feature sets.

I'll be closing this for the time being, but if an equivalent feature is ever considered for addition to spaceship, we can certainly have this feature added here as well. πŸ˜„