Created
January 27, 2021 01:59
-
-
Save dwtompkins/34398fc06aabeb5b335385a95c9352e0 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
# Quick/easy prompt text decorations | |
ansi() { echo -e "\e[${1}m${*:2}\e[0m"; } | |
bold() { ansi 1 "$@"; } | |
italic() { ansi 3 "$@"; } | |
underline() { ansi 4 "$@"; } | |
strikethrough() { ansi 9 "$@"; } | |
# Change color of the PS1 prompt time bashed on bash output | |
__color_change() { | |
if [ $? == 0 ]; then | |
Gre | |
else | |
Red | |
fi | |
} | |
# Quick/easy prompt colors | |
Man() { echo -e "\033[0m"; } | |
Blu() { echo -e "\033[36m"; } | |
Gol() { echo -e "\033[34m"; } | |
Yel() { echo -e "\033[33m"; } | |
Gre() { echo -e "\033[32m"; } | |
Red() { echo -e "\033[31m"; } | |
# Prevent directory listing from wrapping | |
__shortpath() { | |
term_width=$(tput cols) | |
width=term_width-37 | |
if [[ ${#1} -gt width ]]; then | |
len=(width)+3 | |
echo "..."${1: -$len} | |
else | |
echo $1 | |
fi | |
} | |
# Ultimate PS1 | |
PS1="$(Man)┏━[\`__color_change\`\T$(Man)\] \[$(Blu)\]\u@\h \[$(Yel)\]\`__shortpath '\w'\`$(Man)\]\`__git_ps1 ' $(bold $(italic \(%s\)))'\`\]]\n┗━━━━━━▶ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
┏━[09:06:35 dan@xps13 ~/Local Sites/alldev/app/public/wp-content (master)]
┗━━━━━━▶ "Gives you a pretty prompt that looks something like this."