Skip to content

Instantly share code, notes, and snippets.

@manekinekko
Last active February 18, 2020 14:45
Show Gist options
  • Save manekinekko/d8f1c62a3dd55cbe9246fa041042a1cd to your computer and use it in GitHub Desktop.
Save manekinekko/d8f1c62a3dd55cbe9246fa041042a1cd to your computer and use it in GitHub Desktop.
Customize your Oh My Zsh SpaceShip theme with Angular and AngularCLI prompt (https://github.com/denysdovhan/spaceship-prompt)
SPACESHIP_ANGULAR_SHOW="${SPACESHIP_ANGULAR_SHOW:=true}"
SPACESHIP_ANGULAR_PREFIX="${SPACESHIP_ANGULAR_PREFIX:="and "}"
SPACESHIP_ANGULAR_SUFFIX="${SPACESHIP_ANGULAR_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_ANGULAR_SYMBOL="${SPACESHIP_ANGULAR_SYMBOL:="🅰️ "}"
SPACESHIP_ANGULAR_DEFAULT_VERSION="${SPACESHIP_ANGULAR_DEFAULT_VERSION:=""}"
SPACESHIP_ANGULAR_COLOR="${SPACESHIP_ANGULAR_COLOR:="red"}"
_is_angular_project() {
node -p "r=require('./package.json'); r.devDependencies['$1'] || r.dependencies['$1']" 2>/dev/null
}
spaceship_angular() {
[[ $SPACESHIP_ANGULAR_SHOW == false ]] && return
# Show ANGULAR status only inside an NODE/NPM project
# [[ -f package.json || -d node_modules ]] && return
local angular_version=$(_is_angular_project "@angular/core")
[[ $angular_version == "undefined" || $angular_version == "" ]] && return
# SPACESHIP_ANGULAR_PREFIX="("
# SPACESHIP_ANGULAR_SYMBOL="@angular/core@"
# SPACESHIP_ANGULAR_SUFFIX=") "
spaceship::section \
"$SPACESHIP_ANGULAR_COLOR" \
"$SPACESHIP_ANGULAR_PREFIX" \
"${SPACESHIP_ANGULAR_SYMBOL}${angular_version}" \
"$SPACESHIP_ANGULAR_SUFFIX"
}
SPACESHIP_ANGULAR_CLI_SHOW="${SPACESHIP_ANGULAR_CLI_SHOW:=true}"
SPACESHIP_ANGULAR_CLI_PREFIX="${SPACESHIP_ANGULAR_CLI_PREFIX:=""}"
SPACESHIP_ANGULAR_CLI_SUFFIX="${SPACESHIP_ANGULAR_CLI_SUFFIX:="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_ANGULAR_CLI_SYMBOL="${SPACESHIP_ANGULAR_CLI_SYMBOL:="🆑 "}"
SPACESHIP_ANGULAR_CLI_DEFAULT_VERSION="${SPACESHIP_ANGULAR_CLI_DEFAULT_VERSION:=""}"
SPACESHIP_ANGULAR_CLI_COLOR="${SPACESHIP_ANGULAR_CLI_COLOR:="red"}"
_is_angular_project() {
node -p "r=require('./package.json'); r.devDependencies['$1'] || r.dependencies['$1']" 2>/dev/null
}
spaceship_angular_cli() {
[[ $SPACESHIP_ANGULAR_CLI_SHOW == false ]] && return
local angular_cli_version=$(_is_angular_project "@angular/cli")
[[ $angular_cli_version == "undefined" || $angular_cli_version == "" ]] && return
spaceship::section \
"$SPACESHIP_ANGULAR_CLI_COLOR" \
"$SPACESHIP_ANGULAR_CLI_PREFIX" \
"${SPACESHIP_ANGULAR_CLI_SYMBOL}${angular_cli_version}" \
"$SPACESHIP_ANGULAR_CLI_SUFFIX"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment