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
Show git repository folder when inside a git repo #169
Show git repository folder when inside a git repo #169
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR 👏 . Some suggestions
- Don't forget
hg
repos. - Show path from git root and update conditions.
spaceship.zsh
Outdated
"%${SPACESHIP_DIR_TRUNC}~" \ | ||
"$SPACESHIP_DIR_SUFFIX" | ||
_is_git | ||
if [ $? -eq 0 ] && [ $SPACESHIP_DIR_TRUNC_IN_GIT == true ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks my prompt. You could combine these like
if [[ _is_git && $SPACESHIP_DIR_TRUNC_IN_GIT == true ]]; then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm i tried this but didn't work.. Will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked for me. What error were you getting ? Can you try again ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a non git repo this is causing issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a 'new' working solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry. My bad, I didn't test in non-git repository.
spaceship.zsh
Outdated
_prompt_section \ | ||
"$SPACESHIP_DIR_COLOR" \ | ||
"$SPACESHIP_DIR_PREFIX" \ | ||
"${PWD##*/}" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could fetch the root of git repository using git rev-parse --show-toplevel
and path it to by git rev-parse --show-cdup
. Can we use this or other methods to get the path from git root ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't knew this! Will check it out!
spaceship.zsh
Outdated
@@ -84,6 +84,8 @@ SPACESHIP_DIR_SUFFIX="${SPACESHIP_DIR_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX" | |||
SPACESHIP_DIR_TRUNC="${SPACESHIP_DIR_TRUNC:=3}" | |||
SPACESHIP_DIR_COLOR="${SPACESHIP_DIR_COLOR:="cyan"}" | |||
|
|||
SPACESHIP_DIR_TRUNC_IN_GIT=true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the VAR ="${VAR:=value}"
form for variable assignment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was just to show the toggle/option. If that would be something we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This form allow the user to optionally configure the variable value. See parameter expansion for more information.
Also, I think disabling it by default is a good choice.
Thanks for the feedback, that was what i was looking for. I have no experience with |
spaceship.zsh
Outdated
_prompt_section \ | ||
"$SPACESHIP_DIR_COLOR" \ | ||
"$SPACESHIP_DIR_PREFIX" \ | ||
"$(basename $(git rev-parse --show-toplevel))" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thats also what i noted in the PR starter. Don't know if i like that. It should be from git root directory? Don't really know how to do it yet.
Edit: found a working solution.
…aceship-zsh-theme into feature/trunc-before-git
spaceship.zsh
Outdated
_prompt_section \ | ||
"$SPACESHIP_DIR_COLOR" \ | ||
"$SPACESHIP_DIR_PREFIX" \ | ||
"${$(basename $GIT_ROOT)}${$(expr $(pwd) : "$GIT_ROOT\(.*\)")}" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe thanks, it works nice and fast
@sfarzy What is the current status of this PR? Can we exclude hg repo's for now and do that in a separate PR? Do you want it included? I have no experience with hg, so if you could help me on that part you can push it to this branch? |
This PR is already great. Providing |
@RolfKoenders Using |
@sfarzy Cool! Will take a look! Updated! |
@RolfKoenders what the progress with hg implementation? P.S: This PR breaks the basic behavior, so it's gonna be released as a part of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mercurial implementation is required.
I'm gonna rewrite this at #148 |
Trying to fix #141.
It shows the git project root folder and the folders inside.
I'm open for all feedback! Thanks!