Last active
September 11, 2020 03:12
-
-
Save helen/311aed33f7aeb81f5b39daa977b9bfde to your computer and use it in GitHub Desktop.
I still do stuff with Subversion so here's what I have to add a tiny amount of info to my Spaceship prompt
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
# You can put this in your .zshrc | |
# Custom Spaceship section for SVN | |
SPACESHIP_SVN_SHOW="${SPACESHIP_SVN_SHOW=true}" | |
SPACESHIP_SVN_PREFIX="${SPACESHIP_SVN_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" | |
SPACESHIP_SVN_SUFFIX="${SPACESHIP_SVN_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" | |
SPACESHIP_SVN_SYMBOL="${SPACESHIP_SVN_SYMBOL="🐢 "}" | |
SPACESHIP_SVN_COLOR="${SPACESHIP_SVN_COLOR="yellow"}" | |
spaceship_svn() { | |
[[ $SPACESHIP_SVN_SHOW == false ]] && return | |
spaceship::exists svn || return | |
local INFO=$(svn info 2>/dev/null) | |
[ "$INFO" ] || return | |
local 'svn_status' | |
local 'DIRTY' | |
REV=$(printf "%s\n" "$INFO" | grep 'Revision' 2>/dev/null | sed -e 's/Revision: //') | |
[ "$(svn stat --ignore-externals | grep -v '[X?]' 2>/dev/null)" ] && DIRTY='*' | |
svn_status="r${REV}${DIRTY}" | |
# Exit section if variable is empty | |
[[ -z $svn_status ]] && return | |
# Display foobar section | |
spaceship::section \ | |
"$SPACESHIP_SVN_COLOR" \ | |
"$SPACESHIP_SVN_PREFIX" \ | |
"$SPACESHIP_SVN_SYMBOL$svn_status" \ | |
"$SPACESHIP_SVN_SUFFIX" | |
} | |
# Is there a way to add a section without having to define this entire thing? I don't know. | |
SPACESHIP_PROMPT_ORDER=( | |
time # Time stamps section | |
user # Username section | |
dir # Current directory section | |
host # Hostname section | |
svn | |
git # Git section (git_branch + git_status) | |
node # Node.js section | |
exec_time # Execution time | |
line_sep # Line break | |
jobs # Background jobs indicator | |
exit_code # Exit code section | |
char # Prompt character | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment