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

Show git repository folder when inside a git repo #169

Merged
merged 6 commits into from Aug 23, 2017
Merged

Show git repository folder when inside a git repo #169

merged 6 commits into from Aug 23, 2017

Conversation

RolfKoenders
Copy link
Contributor

@RolfKoenders RolfKoenders commented Jul 11, 2017

Trying to fix #141.

It shows the git project root folder and the folders inside.

Truncate git

I'm open for all feedback! Thanks!

Copy link
Member

@salmanulfarzy salmanulfarzy left a 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
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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##*/}" \
Copy link
Member

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 ?

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

@RolfKoenders
Copy link
Contributor Author

Thanks for the feedback, that was what i was looking for. I have no experience with hg but will look into it once i got the git repo to work.

spaceship.zsh Outdated
_prompt_section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"$(basename $(git rev-parse --show-toplevel))" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this show sub directories ? Now I'm getting only the root directory. See here, logos sub directory is not shown.

image

Copy link
Contributor Author

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.

spaceship.zsh Outdated
_prompt_section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"${$(basename $GIT_ROOT)}${$(expr $(pwd) : "$GIT_ROOT\(.*\)")}" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice solution 👍

Copy link
Contributor Author

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 ☺️

@RolfKoenders
Copy link
Contributor Author

@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?

@salmanulfarzy
Copy link
Member

This PR is already great. Providing hg support into this would cover one more use case or we could add it later. Let's also wait for opinion from @denysdovhan.

@salmanulfarzy
Copy link
Member

@RolfKoenders Using $var:t performs way better than basename. Please take a look at #173 (comment) and zsh modifiers

@RolfKoenders
Copy link
Contributor Author

RolfKoenders commented Jul 17, 2017

@sfarzy Cool! Will take a look! Updated!

@denysdovhan denysdovhan added improvement A PR that make small changes for improving UX, performance, readability, etc proposal An issue (rarely PR) for feature-requests, ideas, etc breaking ‼️ BREAKING CHANGES ‼️ All breaking changes go under major release. labels Aug 20, 2017
@denysdovhan
Copy link
Member

@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 v3.0.

Copy link
Member

@denysdovhan denysdovhan left a 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.

@denysdovhan denysdovhan mentioned this pull request Aug 22, 2017
25 tasks
@denysdovhan denysdovhan changed the base branch from master to 3.0 August 23, 2017 15:02
@denysdovhan
Copy link
Member

I'm gonna rewrite this at #148

@denysdovhan denysdovhan merged commit 429d832 into spaceship-prompt:3.0 Aug 23, 2017
@RolfKoenders RolfKoenders deleted the feature/trunc-before-git branch August 23, 2017 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking ‼️ BREAKING CHANGES ‼️ All breaking changes go under major release. improvement A PR that make small changes for improving UX, performance, readability, etc proposal An issue (rarely PR) for feature-requests, ideas, etc
Development

Successfully merging this pull request may close these issues.

None yet

3 participants