Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of ~/.zshrc #141

Open
LDAmorim opened this issue Mar 4, 2020 · 5 comments
Open

Example of ~/.zshrc #141

LDAmorim opened this issue Mar 4, 2020 · 5 comments

Comments

@LDAmorim
Copy link

LDAmorim commented Mar 4, 2020

Hi,

I only learned about your project recently and already find it really useful!

I am not sure if this is the best place for me to share this or if it is important, so feel free to delete this issue.

I just thought an "example" configuration could help people save some time looking for this.
The system I tested this in is a macOS Catalina.

Please feel free to let me know if there is a better way to implement this example.

Thank you for this repo,
Diana


Example

So that whenever I switch to a new folder it tests if it is a git repo and if it is calls the PROMPT option, if not keeps it a zsh shell. I added the example lines below to ~/.zshrc

function chpwd {
TEST_git=$(git rev-parse --is-inside-work-tree) 2>/dev/null
if [ "$TEST_git" = "true" ]; then
      pwd
      source /Users/LDianaAmorim/Documents/opt/zsh-git-prompt/zshrc.sh
      # an example prompt
      PROMPT='%B%m%~%b$(git_super_status) %# '
else
      exec zsh
fi
}

I had to create that file (before I only had ~/.zprofile) and decided not to use the .sh termination as is consistent with other profile files.

@iamalexaz
Copy link

can i ask how to fix git super status error?

@LDAmorim
Copy link
Author

Hi! Could you please share the error message?

@craftyguy
Copy link

invoking git every time might be kinda slow, it's faster to do something like [ -d .git ]. It's probably(?) unlikely there would be a .git directory in pwd that is not a git repo :)

@thomasrebele
Copy link

@craftyguy, the git directory exists only at the root of the git repository. The check would need to look recursively at the parent directories as well.

If you want a faster git prompt, you could try https://github.com/zsh-git-prompt/zsh-git-prompt/. It uses the shell directly, avoiding the startup cost of Python or Haskell.

@craftyguy
Copy link

@craftyguy, the git directory exists only at the root of the git repository. The check would need to look recursively at the parent directories as well.

If you want a faster git prompt, you could try https://github.com/zsh-git-prompt/zsh-git-prompt/. It uses the shell directly, avoiding the startup cost of Python or Haskell.

ah yes, good point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants