Last active
June 1, 2021 01:59
-
-
Save varenc/37e540568bb6ffafb00812a23ce9ebb8 to your computer and use it in GitHub Desktop.
Turn off oh-my-zsh's git prompt info in certain directories (useful for networked/rclone mount filesystems/Dropbox/GDrive)
This file contains hidden or 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
# Sometimes you don't want zsh/oh-my-zsh to show you the git status under certain paths | |
# | |
# For example, on a networked file systems (like Dropbox/GDrive or an rclone mount) | |
# oh-my-zsh's git prompt can slow things down. It calls `git` which then needs to | |
# look for a `.git` directory that probably doesn't exist. Sometimes this will force | |
# a query to the server so that the server can confirm that indeed, a `.git` directory | |
# does not exist in the current location. Or if it does it'll fetch all the contents | |
# (git also needs to check all your parent dirs for a `.git` folder as well...) | |
# Here's a simple solution. Put this where your other custimization are or just in `~/.zshrc` | |
function git_prompt_info_wrapper() { | |
# returns true if `/rclone_mount_filesystem/` is anywhere in your current path | |
if ( | |
[[ $PWD/ = */rclone_mount_filesystem/* ]] || | |
[[ $PWD/ = */Dropbox/* ]] | |
) ; | |
then | |
# uncomment these for help debugging | |
# (>&2 echo "skipping git status checks!") | |
else | |
# (>&2 echo "not skipping git status checks") | |
git_prompt_info; | |
fi | |
} | |
# Just replace `git_prompt_info` with `git_prompt_info_wrapper` in your PROMPT env | |
export PROMPT='${ret_status} %{$fg[cyan]%}%2d%{$reset_color%} $(git_prompt_info_wrapper)' | |
# if you don't define your own PROMPT and use the default, then you can get your current PROMPT | |
# by running `echo $PROMPT`. Or just paste in mine. | |
### TODO: Do something smarter instead of looking for a string in the path. Just check if the current dir is part of a mounted filesystem? |
wow glad someone finally found this! 🎉
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this!