Skip to content

Instantly share code, notes, and snippets.

@DenWav
Last active February 21, 2016 01:05
Show Gist options
  • Select an option

  • Save DenWav/cb5dcbc96de584a8372b to your computer and use it in GitHub Desktop.

Select an option

Save DenWav/cb5dcbc96de584a8372b 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"
DIR="$(echo $DIR | sed "s|$HOME|~|")"
echo -e "\n┌─[$STATUS]─[$WHOAMI@$RESET$CYAN$HOSTNAME$RESET]─$GIT\
[$GREEN$DIR$RESET]\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