Skip to content

Instantly share code, notes, and snippets.

@dwtompkins
Created January 27, 2021 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwtompkins/34398fc06aabeb5b335385a95c9352e0 to your computer and use it in GitHub Desktop.
Save dwtompkins/34398fc06aabeb5b335385a95c9352e0 to your computer and use it in GitHub Desktop.
# 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┗━━━━━━▶ "
@l00sed
Copy link

l00sed commented Jan 27, 2021

┏━[09:06:35 dan@xps13 ~/Local Sites/alldev/app/public/wp-content (master)]
┗━━━━━━▶ "Gives you a pretty prompt that looks something like this."

@l00sed
Copy link

l00sed commented Jan 27, 2021

More bash goodness available in the knowledge base:
https://l-o-o-s-e-d.net/kb/bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment