A collection of scripts and configurations for Bash (and others)
No puede seleccionar más de 25 temasLos temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
# This function was modified from one found @ https://www.reddit.com/r/linux/comments/2uf5uu/this_is_my_bash_prompt_which_is_your_favorite/?st=jikgswh4&sh=371ba8bf
# $1 - Default text (foreground) color
# $2 - Background color
function section_git_status() {
local default untracked stash clean ahead behind staged dirty diverged
default=$(_CC $1 $2)
untracked=$(_CC $GREEN $2)
stash=$(_CC $GREEN $2)
clean=$(_CC $GREEN $2)
ahead=$(_CC $YELLOW $2)
behind=$(_CC $YELLOW $2)
staged=$(_CC $CYAN $2)
dirty=$(_CC $RED $2)
diverged=$(_CC $RED $2)
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ -n "$branch" ]]; then
if [ "$last_section_bg" ]; then
section_separator $1 $2
fi
last_section_bg=$2
PS1+="${default} ${symbols[git]} $branch "
git_status=$(git status 2> /dev/null)
# If nothing changes the color, we can spot unhandled cases.
if [[ $git_status =~ 'Untracked files' ]]; then
PS1+="${symbols[untracked]}"
fi
if git stash show &>/dev/null; then
PS1+="${symbols[stash]}"
fi
if [[ $git_status =~ 'Your branch is ahead' ]]; then
PS1+="${symbols[ahead]}"
fi
if [[ $git_status =~ 'Your branch is behind' ]]; then
PS1+="${symbols[behind]}"
fi
if [[ $git_status =~ 'Changes to be committed' ]]; then
PS1+="${symbols[tick]}"
fi
if [[ $git_status =~ 'Changed but not updated' ||
$git_status =~ 'Changes not staged' ||
$git_status =~ 'Unmerged paths' ]]; then
PS1+="${symbols[cross]}"
fi
if [[ $git_status =~ 'Your branch'.+diverged ]]; then
PS1+="${symbols[enter]}"
fi
PS1+=" "
fi
}
# $1 - FG local
# $2 - BG User
# $3 - FG Remote
# $4 - BG Root
section_tty () {
local TTY=`ps aux | grep $$ | grep bash | awk '{ print $7 }'`