`nvm alias`: colorize LTS aliases.

Jordan Harband 2016-04-30 12:50:59 -07:00
parent c83664960e
commit bf683272ea
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
1 changed files with 10 additions and 4 deletions

14
nvm.sh
View File

@ -491,11 +491,17 @@ nvm_print_formatted_alias() {
DEST_FORMAT='\033[1;31m%s\033[0m' DEST_FORMAT='\033[1;31m%s\033[0m'
VERSION_FORMAT='\033[1;31m%s\033[0m' VERSION_FORMAT='\033[1;31m%s\033[0m'
fi fi
if [ "_${NVM_LTS-}" = '_true' ]; then
ALIAS_FORMAT='\033[1;33m%s\033[0m'
fi
if [ "_${DEST%/*}" = "_lts" ]; then
DEST_FORMAT='\033[1;33m%s\033[0m'
fi
fi fi
if [ "_$DEST" = "_$VERSION" ]; then if [ "_$DEST" = "_$VERSION" ]; then
command printf "${ALIAS_FORMAT} ${ARROW} ${VERSION_FORMAT}${NEWLINE}" "$ALIAS" "$DEST" command printf -- "${ALIAS_FORMAT} ${ARROW} ${VERSION_FORMAT}${NEWLINE}" "$ALIAS" "$DEST"
else else
command printf "${ALIAS_FORMAT} ${ARROW} ${DEST_FORMAT} (${ARROW} ${VERSION_FORMAT})${NEWLINE}" "$ALIAS" "$DEST" "$VERSION" command printf -- "${ALIAS_FORMAT} ${ARROW} ${DEST_FORMAT} (${ARROW} ${VERSION_FORMAT})${NEWLINE}" "$ALIAS" "$DEST" "$VERSION"
fi fi
} }
@ -517,7 +523,7 @@ nvm_print_alias_path() {
local DEST local DEST
DEST="$(nvm_alias "$ALIAS" 2> /dev/null || return 0)" DEST="$(nvm_alias "$ALIAS" 2> /dev/null || return 0)"
if [ -n "$DEST" ]; then if [ -n "$DEST" ]; then
DEFAULT=false nvm_print_formatted_alias "$ALIAS" "$DEST" NVM_LTS="${NVM_LTS-}" DEFAULT=false nvm_print_formatted_alias "$ALIAS" "$DEST"
fi fi
} }
@ -2602,7 +2608,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | nvm_grep -v "N/A" | command sed '/^$/d')"
local LTS_ALIAS local LTS_ALIAS
for ALIAS_PATH in "$NVM_ALIAS_DIR/lts/${2-}"*; do for ALIAS_PATH in "$NVM_ALIAS_DIR/lts/${2-}"*; do
LTS_ALIAS="$(nvm_print_alias_path "$NVM_ALIAS_DIR" "$ALIAS_PATH")" LTS_ALIAS="$(NVM_LTS=true nvm_print_alias_path "$NVM_ALIAS_DIR" "$ALIAS_PATH")"
if [ -n "$LTS_ALIAS" ]; then if [ -n "$LTS_ALIAS" ]; then
nvm_echo "${LTS_ALIAS-}" nvm_echo "${LTS_ALIAS-}"
fi fi