Last active
February 25, 2023 21:10
-
-
Save hugoalmeidahh/c6e6dc938f3f22d039fcbc43b49adabc to your computer and use it in GitHub Desktop.
This file contains 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
#colors | |
NORMAL='\033[0m' | |
RED='\033[00;31m' | |
GREEN='\033[00;32m' | |
YELLOW='\033[00;33m' | |
BLUE='\033[00;34m' | |
PURPLE='\033[00;35m' | |
CYAN='\033[00;36m' | |
LIGHTGRAY='\033[00;37m' | |
LRED='\033[01;31m' | |
LGREEN='\033[01;32m' | |
LYELLOW='\033[01;33m' | |
LBLUE='\033[01;34m' | |
LPURPLE='\033[01;35m' | |
LCYAN='\033[01;36m' | |
WHITE='\033[01;37m' | |
UNDERLINE='\033[04m' | |
ENDCOLOR="\033[1;40m" | |
BGRED='\033[01;31;40m' # BG Dark Gray | |
BGGREEN='\033[00;32;40m' # BG Dark Gray | |
BGYELLOW='\033[01;30;43m' # BG Dark Gray | |
BGYELLOWDGREEN='\033[00;30;43' | |
# \e[42mGreen Background\e[0m | |
#echo -e "${RED}Red text${ENDCOLOR}" | |
#script | |
is_go_version(){ | |
if ! command -v go &> /dev/null | |
then | |
echo '' #-e "${BGGREEN}[ 🔰 GO not found ]${ENDCOLOR}" | |
exit | |
fi | |
version=`go version | cut -f 3 -d ' '` | |
if [ "$version" != "" ]; then | |
version="[🐹"$version"]" | |
echo -e "${BGGREEN}$version${ENDCOLOR}" | |
exit | |
fi | |
} | |
is_node_version(){ | |
if ! command -v node &> /dev/null | |
then | |
echo -e "${BGGREEN}[ 🔰 NodeJS not found ]${ENDCOLOR}" | |
exit | |
fi | |
version=`node --version` | |
if [ "$version" != "" ]; then | |
version="[🔰:"$version"]" | |
echo -e "${BGGREEN}$version${ENDCOLOR}" | |
exit | |
fi | |
} | |
is_package_version(){ | |
FILE=package.json | |
if [ -f "$FILE" ]; then | |
PKG_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g') | |
if [ "$PKG_VERSION" != "" ]; then | |
echo -e ${BGYELLOW}$PKG_VERSION ${ENDCOLOR} | |
exit | |
fi | |
echo "" | |
exit | |
fi | |
} | |
is_git(){ | |
str=` git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
if [ "$str" != "" ]; then | |
if [ ! -z "$(git status --porcelain 2>/dev/null)" ]; then | |
str="${BGRED} ("🚩$str") " | |
else | |
str="${BGGREEN} ("$str${ENDCOLOR}") " | |
fi | |
echo -e $str | |
fi | |
} | |
### Long version | |
#PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;11m\]\t\[$(tput sgr0)\] \[\033[01;32m\]\u@\h\[\033[00m\]:[$(is_node_version)]:\[\033[01;34m\]\w\[\033[38;5;196m\] $(is_git)\[\033[00m\]\$ ' | |
### Shorter version, without username@hostname | |
#PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;11m\]\t\[$(tput sgr0)\] \[\033[01;32m\]\w\[\033[38;5;196m\] $(is_git)\[\033[00m\]\n\$ ' | |
### Time, UserName, NodeVersion, pathFolders, GitBranch | |
#PS1='${debian_chroot:+($debian_chroot)}👾 \[\033[01;30;43m\] \t \[\033[01;32;40m\] \u $(is_node_version): \[\033[00;30;101m\] \w \033[00m$(is_git) \[\033[00m\]\$ ' | |
### Time, UserName, NodeVersion, pathFolders, GitBranch, NewLine | |
PS1='${debian_chroot:+($debian_chroot)}👾 \[\033[01;30;43m\] \t \[\033[01;32;40m\] \u $(is_node_version):$(is_go_version) \[\033[00;30;101m\] \w $(is_package_version) \033[00m$(is_git) \[\033[00m\]\n\$ ' | |
### Other Examples | |
#PS1="[\\u@\\H \\W \\@]\\$ " | |
#PS1="\[\e[32m\][\[\e[m\]\[\e[31m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]:\[\e[36m\]\w\[\e[m\]\[\e[32m\]]\[\e[m\]\[\e[32;47m\]\\$\[\e[m\] " | |
#PS1="\[\e[34;45m\]\w\[\e[m\]\[\e[35m\]▶\[\e[m\] " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment