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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 17 additions & 5 deletions spaceship.zsh
Expand Up @@ -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="${SPACESHIP_DIR_TRUNC_IN_GIT:=false}"

# GIT
SPACESHIP_GIT_SHOW="${SPACESHIP_GIT_SHOW:=true}"
SPACESHIP_GIT_PREFIX="${SPACESHIP_GIT_PREFIX:="on "}"
Expand Down Expand Up @@ -446,11 +448,21 @@ spaceship_host() {
spaceship_dir() {
[[ $SPACESHIP_DIR_SHOW == false ]] && return

_prompt_section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"%${SPACESHIP_DIR_TRUNC}~" \
"$SPACESHIP_DIR_SUFFIX"
if _is_git && [[ $SPACESHIP_DIR_TRUNC_IN_GIT == true ]]; then
GIT_ROOT=$(git rev-parse --show-toplevel)

_prompt_section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"$GIT_ROOT:t${$(expr $(pwd) : "$GIT_ROOT\(.*\)")}" \
"$SPACESHIP_DIR_SUFFIX"
else
_prompt_section \
"$SPACESHIP_DIR_COLOR" \
"$SPACESHIP_DIR_PREFIX" \
"%${SPACESHIP_DIR_TRUNC}~" \
"$SPACESHIP_DIR_SUFFIX"
fi
}

# GIT BRANCH
Expand Down