Created
September 26, 2023 19:12
-
-
Save connoro7/cb51b6cfdf50421afb9b91cf38684cf8 to your computer and use it in GitHub Desktop.
ps1
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
# Customize BASH PS1 prompt to show current GIT repository and branch. | |
# by Mike Stewart - http://MediaDoneRight.com | |
# SETUP CONSTANTS | |
# Bunch-o-predefined colors. Makes reading code easier than escape sequences. | |
# I don't remember where I found this. o_O | |
# Reset | |
Color_Off=$'\033[0m' # Text Reset | |
# Regular Colors | |
export Black=$'\033[0;30m' # Black | |
export Red=$'\033[0;31m' # Red | |
export Green=$'\033[0;32m' # Green | |
export Yellow=$'\033[0;33m' # Yellow | |
export Blue=$'\033[0;34m' # Blue | |
export Purple=$'\033[0;35m' # Purple | |
export Cyan=$'\033[0;36m' # Cyan | |
export White=$'\033[0;37m' # White | |
# Bold | |
export BBlack=$'\033[1;30m' # Black | |
export BRed=$'\033[1;31m' # Red | |
export BGreen=$'\033[1;32m' # Green | |
export BYellow=$'\033[1;33m' # Yellow | |
export BBlue=$'\033[1;34m' # Blue | |
export BPurple=$'\033[1;35m' # Purple | |
export BCyan=$'\033[1;36m' # Cyan | |
export BWhite=$'\033[1;37m' # White | |
# Underline | |
export UBlack=$'\033[4;30m' # Black | |
export URed=$'\033[4;31m' # Red | |
export UGreen=$'\033[4;32m' # Green | |
export UYellow=$'\033[4;33m' # Yellow | |
export UBlue=$'\033[4;34m' # Blue | |
export UPurple=$'\033[4;35m' # Purple | |
export UCyan=$'\033[4;36m' # Cyan | |
export UWhite=$'\033[4;37m' # White | |
# Background | |
export On_Black=$'\033[0;37;40m' # Black | |
export On_Red=$'\033[41m' # Red | |
export On_Green=$'\033[42m' # Green | |
export On_Yellow=$'\033[43m' # Yellow | |
export On_Blue=$'\033[44m' # Blue | |
export On_Purple=$'\033[45m' # Purple | |
export On_Cyan=$'\033[46m' # Cyan | |
export On_White=$'\033[0;30;47m' # White | |
# High Intensty | |
export IBlack=$'\033[0;90m' # Black | |
export IRed=$'\033[0;91m' # Red | |
export IGreen=$'\033[0;92m' # Green | |
export IYellow=$'\033[0;93m' # Yellow | |
export IBlue=$'\033[0;94m' # Blue | |
export IPurple=$'\033[0;95m' # Purple | |
export ICyan=$'\033[0;96m' # Cyan | |
export IWhite=$'\033[0;97m' # White | |
# Bold High Intensty | |
export BIBlack=$'\033[1;90m' # Black | |
export BIRed=$'\033[1;91m' # Red | |
export BIGreen=$'\033[1;92m' # Green | |
export BIYellow=$'\033[1;93m' # Yellow | |
export BIBlue=$'\033[1;94m' # Blue | |
export BIPurple=$'\033[1;95m' # Purple | |
export BICyan=$'\033[1;96m' # Cyan | |
export BIWhite=$'\033[1;97m' # White | |
# High Intensty backgrounds | |
export On_IBlack=$'\033[0;37;100m' # Black | |
export On_IRed=$'\033[0;101m' # Red | |
export On_IGreen=$'\033[0;102m' # Green | |
export On_IYellow=$'\033[0;103m' # Yellow | |
export On_IBlue=$'\033[0;104m' # Blue | |
export On_IPurple=$'\033[10;95m' # Purple | |
export On_ICyan=$'\033[0;106m' # Cyan | |
export On_IWhite=$'\033[0;30;107m' # White | |
# Blink | |
export Blink=$'\033[5m' # Blinking text | |
export ResetBlink=$'\033[25m' # Removes blinking text | |
# Statuses | |
export Info=$'\033[0;44;97m' # Blue background | |
export Warning=$'\033[0;101;97m' # Red background | |
export Success=$'\033[0;102;30m' # Green background | |
export Highlight=$'\033[0;43;30m' # Yellow background | |
# Various variables you might want for your PS1 prompt instead | |
Time12h="\T" | |
Time12a="\@" | |
PathShort="\w" | |
PathFull="\W" | |
NewLine="\n" | |
Jobs="\j" | |
Prompt="λ" # ✗ $ λ Σ Ξ Π ⛬ ☭ ⛧ ⛏ | |
# Locale, `locale -a` to list available locales | |
# Make sure `locale` v | |
export LC_ALL="en_US.UTF-8" | |
command_exists () { | |
type "$1" > /dev/null 2>&1 ; | |
} | |
if command_exists scutil ; then | |
# OS X | |
COMPUTER_NAME="$(scutil --get ComputerName)" | |
else | |
# Standard | |
COMPUTER_NAME="\h" | |
fi | |
source ~/.git-completion.bash | |
source ~/.git-prompt.sh | |
# This PS1 snippet was adopted from code for MAC/BSD from: http://allancraig.net/index.php?option=com_content&view=article&id=108:ps1-export-command-for-git&catid=45:general&Itemid=96 | |
# It was tweaked to work on UBUNTU 11.04 & 11.10 and be mo' better | |
# export PS1='\n'$Cyan$COMPUTER_NAME$IBlack'\n'$Time12h$Color_Off'$(git branch &>/dev/null;\ | |
# export PS1='\n'$IBlack$Time12h' '$Cyan$COMPUTER_NAME$Color_Off'$(git branch &>/dev/null;\ | |
export PS1='\n'$IBlack$Time12h' $(git branch &>/dev/null;\ | |
if [ $? -eq 0 ]; then \ | |
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \ | |
if [ "$?" -eq "0" ]; then \ | |
# @4 - Clean repository - nothing to commit | |
echo "'$Green'"$(__git_ps1 " (%s)"); \ | |
else \ | |
# @5 - Changes to working tree | |
echo "'$IRed'"$(__git_ps1 " {%s}"); \ | |
fi) '$Blue$PathFull$Color_Off'\n$Prompt "; \ | |
else \ | |
# @2 - Prompt when not in GIT repo | |
echo " '$Yellow$PathShort$Color_Off'\n$Prompt "; \ | |
fi)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment