Last active
November 19, 2019 10:32
-
-
Save b00f/6e7f005bdaab80c3be16e69f607f15fb to your computer and use it in GitHub Desktop.
random prefix symbol for spaceship-prompt plugin
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
# | |
# Prompt character | |
# | |
# ------------------------------------------------------------------------------ | |
# Configuration | |
# ------------------------------------------------------------------------------ | |
PREFIXES="πππππΈπ½π«β½π½π»ππ¨π΅π¦πΎπ¦π³π¦ββ½π―πΎπ‘πΊπΈππ¬βπΎβ°βͺπ±" | |
SPACESHIP_CHAR_PREFIX="${SPACESHIP_CHAR_PREFIX=""}" | |
SPACESHIP_CHAR_SUFFIX="${SPACESHIP_CHAR_SUFFIX=""}" | |
SPACESHIP_CHAR_SYMBOL="${SPACESHIP_CHAR_SYMBOL="β "}" | |
SPACESHIP_CHAR_SYMBOL_ROOT="${SPACESHIP_CHAR_SYMBOL_ROOT="$SPACESHIP_CHAR_SYMBOL"}" | |
SPACESHIP_CHAR_SYMBOL_SECONDARY="${SPACESHIP_CHAR_SYMBOL_SECONDARY="$SPACESHIP_CHAR_SYMBOL"}" | |
SPACESHIP_CHAR_COLOR_SUCCESS="${SPACESHIP_CHAR_COLOR_SUCCESS="green"}" | |
SPACESHIP_CHAR_COLOR_FAILURE="${SPACESHIP_CHAR_COLOR_FAILURE="red"}" | |
SPACESHIP_CHAR_COLOR_SECONDARY="${SPACESHIP_CHAR_COLOR_SECONDARY="yellow"}" | |
# ------------------------------------------------------------------------------ | |
# Section | |
# ------------------------------------------------------------------------------ | |
# Paint $PROMPT_SYMBOL in red if previous command was fail and | |
# paint in green if everything was OK. | |
spaceship_char() { | |
local 'color' 'char' | |
if [[ $RETVAL -eq 0 ]]; then | |
color="$SPACESHIP_CHAR_COLOR_SUCCESS" | |
else | |
color="$SPACESHIP_CHAR_COLOR_FAILURE" | |
fi | |
if [[ $UID -eq 0 ]]; then | |
char="$SPACESHIP_CHAR_SYMBOL_ROOT" | |
else | |
char="$SPACESHIP_CHAR_SYMBOL" | |
fi | |
prefix="$SPACESHIP_CHAR_PREFIX" | |
if [[ $TERM_PROGRAM != "vscode" ]]; then | |
RND=$(shuf -i 1-${#PREFIXES} -n 1)-1 | |
prefix="${PREFIXES:$RND:1} " | |
fi | |
spaceship::section \ | |
"$color" \ | |
"$prefix" \ | |
"$char" \ | |
"$SPACESHIP_CHAR_SUFFIX" | |
} |
Author
b00f
commented
Aug 31, 2019
- Install oh-my-zsh
- Install spaceship-prompt plugin
- Update char.zsh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment