Skip to content

Instantly share code, notes, and snippets.

@willies952002
Created June 16, 2016 23:15
Show Gist options
  • Save willies952002/9196e7718c61d1747615f10869a4be95 to your computer and use it in GitHub Desktop.
Save willies952002/9196e7718c61d1747615f10869a4be95 to your computer and use it in GitHub Desktop.
#!/bin/bash
SUCCESS="$1"
USERNAME="$2"
HOSTNAME="$3"
DIR="$4"
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
BLUE="$(tput setaf 4)"
CYAN="$(tput setaf 6)"
YELLOW="$(tput setaf 3)"
WHITE="$(tput setaf 7)"
DIM="$(tput dim)"
RESET="$(tput sgr0)"
IS_GIT="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
[[ "$IS_GIT" == "true" ]] && GIT="[$YELLOW$(git branch | sed -n '/\* /s///p' | sed 's/(\|)//g' | sed "s/detached at/${DIM}detached at$RESET$YELLOW/")$RESET]─"
[[ "$USERNAME" == "root" ]] && WHOAMI="$RED" || WHOAMI="$BLUE" ; WHOAMI="$WHOAMI$2$RESET"
#[[ "$SUCCESS" == "0" ]] && STATUS="$GREEN✓" || STATUS="$RED✗" ; STATUS="$STATUS$RESET"
[[ "$SUCCESS" == "0" ]] && STATUS="$GREEN█" || STATUS="$RED█" ; STATUS="$STATUS$RESET"
DIR="$(echo $DIR | sed "s|$HOME|~|")"
TIME=$(date +%T)
echo -e "\n┌─┤$STATUS├─[$WHOAMI@$RESET$CYAN$HOSTNAME$RESET]─$GIT[$GREEN$DIR$RESET]─[$TIME]\n└──╼ "
unset SUCCESS ; unset USERNAME ; unset HOSTNAME ; unset DIR ; unset RED
unset GREEN ; unset BLUE ; unset CYAN ; unset YELLOW ; unset WHITE ; unset DIM
unset RESET ; unset IS_GIT ; unset GIT ; unset WHOAMI ; unset STATUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment