Last active
August 3, 2021 22:10
-
-
Save wesleyit/8b5ac23a70fd1d10a48df243bbfeb0da to your computer and use it in GitHub Desktop.
A very nice command prompt for BASH :D
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
# Ensure you are evaluating PS1 var instead a command for prompt | |
unset PROMPT_COMMAND | |
# Change these symbols for the ones available on the font | |
# you are using in your terminal. This ones works in Agave Nerd Font. | |
USER_SYM=' ' | |
ROOT_SYM=' ' | |
GIT_SYM='' | |
VENV_SYM='' | |
AWS_SYM='' | |
# Don't change after this point | |
ESC='\e[' | |
END='\e[m' | |
RST='\e[0;0m' | |
## Set git options | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export GIT_PS1_SHOWSTASHSTATE=1 | |
export GIT_PS1_SHOWUNTRACKEDFILES=1 | |
export GIT_PS1_SHOWUPSTREAM="auto" | |
export GIT_PS1_SHOWCOLORHINTS=1 | |
export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
if [ "$UID" -eq "0" ]; then | |
COLOR='01;31m' | |
SYM="$ROOT_SYM" | |
INDICATOR='#' | |
else | |
COLOR='01;32m' | |
SYM="$USER_SYM" | |
INDICATOR='$' | |
fi | |
ps_user="\[${ESC}${COLOR}\]${USER}\[${END}\]" | |
ps_sym="\[${ESC}${COLOR}\]${SYM}\[${END}\]" | |
ps_host="\[${ESC}${COLOR}\]${HOSTNAME}\[${END}\]" | |
ps_path="\[${ESC}${COLOR}\]${PWD}\[${END}\]" | |
ps_priv="\[${ESC}${COLOR}\]${INDICATOR}\[${END}\]" | |
function ps_venv() { | |
local COLOR='01;33m' | |
[[ -z "$VIRTUAL_ENV" ]] || | |
echo -ne "──[${ESC}${COLOR}${VENV_SYM} virtualenv${END}]" | |
} | |
function ps_aws() { | |
local COLOR='01;33m' | |
if env | egrep -q 'AWS_PROFILE|AWS_ACCESS_KEY_ID'; then | |
echo -ne "──[${ESC}${COLOR}${AWS_SYM} aws${END}]" | |
fi | |
} | |
function ps_git() { | |
local COLOR='01;35m' | |
if git status &> /dev/null; then | |
echo -ne "──[${ESC}${COLOR}${GIT_SYM} git$(__git_ps1)${END}]" | |
fi | |
} | |
export PS1=" | |
╭──[$ps_user $ps_sym $ps_host]──[$ps_path]\$(ps_venv)\$(ps_aws)\$(ps_git) | |
│ | |
╰──$ps_priv " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment