antonmedv/countdown

Your prompt

retr0h opened this issue · 2 comments

This isn't really related to countdown, but in the gif on the main page, you have a pretty rad colorful prompt. Any chance you could provide the details on how to accomplish that ;)

Thanks!

Here it is:

image

# Prompt

PATH_COLOR="\[$(tput setaf 47)\]"
GIT_BRANCH_COLOR="\[$(tput setaf 51)\]"
PROMPT_COLOR="\[$(tput setaf 76)\]"
COLOR_RED="\[$(tput setaf 161)\]"
COLOR_YELLOW="\[$(tput setaf 220)\]"
COLOR_GREEN="\[$(tput setaf 76)\]"
RESET="\[$(tput sgr0)\]"

function find_git_branch {
  local branch
  if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then
    if [[ "$branch" == "HEAD" ]]; then
      branch='detached*'
    fi
    GIT_BRANCH=" ${GIT_BRANCH_COLOR}$branch${RESET}"
  else
    GIT_BRANCH=""
  fi
}

function set_tab_title {
	echo -ne "\033]0;${PWD##*/}\007"
}

function set_ps1 {	
	find_git_branch;
	set_tab_title;
	if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
  	export PS1="${PATH_COLOR}\W${RESET}${GIT_BRANCH} ${COLOR_RED}${COLOR_YELLOW}${COLOR_GREEN}${RESET} "
	else
		export PS1="\W ❯ "
	fi
}

export PROMPT_COMMAND="set_ps1;"

Thanks 👍 \m/