Last active
July 29, 2021 20:22
-
-
Save brunurd/f3c1b3902aad37dcfceab959b58a09aa to your computer and use it in GitHub Desktop.
PS1 bolado
This file contains hidden or 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
#!/bin/bash | |
DEFAULT="\[\033[0;00m\]" | |
RED="\[\033[1;31m\]" | |
GREEN="\[\033[0;32m\]" | |
YELLOW="\[\033[0;33m\]" | |
PURPLE="\[\033[0;35m\]" | |
CYAN="\[\033[0;36m\]" | |
__error_red_num() { | |
test "$?" = "0" || echo -e "\033[1;31m $?" | |
} | |
__sys_name() { | |
sys_name= | |
command -v uname 1>/dev/null && \ | |
command -v head 1>/dev/null && \ | |
command -v awk 1>/dev/null && \ | |
command -v cat 1>/dev/null && \ | |
command -v grep 1>/dev/null && \ | |
command -v sed 1>/dev/null && { | |
os=$(uname -a | head -n1 | awk '{print $1;}') | |
if [ "$os" = "Linux" ] ; then | |
test -f /etc/os-release 2>/dev/null && sys_name=$(cat /etc/os-release | grep ^NAME= | sed 's/NAME="//g' | sed 's/"//g') | |
else | |
sys_name="$os" | |
fi | |
} | |
echo -e "$PURPLE$sys_name" | |
} | |
test -z $(__git_ps1 2>/dev/null) && { | |
__git_ps1() { | |
command -v git 1>/dev/null && \ | |
test -d .git && \ | |
printf "$1" "$(git branch --show-current)" | |
} | |
} | |
export PS1=$GREEN"\u@\h"$YELLOW" \w $(__sys_name)"$CYAN'$(__git_ps1 " (%s)")$(__error_red_num)'$DEFAULT"\n\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment