configs/home/.zsh/themes/spaceship-prompt/sections/exit_code.zsh

30 lines
1.0 KiB
Bash
Raw Permalink Normal View History

2022-12-01 13:28:20 +01:00
#
# Exit code
#
# Show exit code of last executed command
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
SPACESHIP_EXIT_CODE_SHOW="${SPACESHIP_EXIT_CODE_SHOW=false}"
SPACESHIP_EXIT_CODE_PREFIX="${SPACESHIP_EXIT_CODE_PREFIX=""}"
SPACESHIP_EXIT_CODE_SUFFIX="${SPACESHIP_EXIT_CODE_SUFFIX=" "}"
SPACESHIP_EXIT_CODE_SYMBOL="${SPACESHIP_EXIT_CODE_SYMBOL="✘"}"
SPACESHIP_EXIT_CODE_COLOR="${SPACESHIP_EXIT_CODE_COLOR="red"}"
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
spaceship_exit_code() {
[[ $SPACESHIP_EXIT_CODE_SHOW == false || $RETVAL == 0 ]] && return
spaceship::section \
--color "$SPACESHIP_EXIT_CODE_COLOR" \
--prefix "$SPACESHIP_EXIT_CODE_PREFIX" \
--suffix "$SPACESHIP_EXIT_CODE_SUFFIX" \
--symbol "$SPACESHIP_EXIT_CODE_SYMBOL" \
"$RETVAL"
}