#!/bin/bash # Bash Prompt WHOAMI=$(id -un) if [ "$WHOAMI" = "root" ] ; then PATHCOLOR='\[\033[01;31m\]' PROMPTCHR='\[\033[00;31m\]#' SHOWUSER="" elif [ "$WHOAMI" == "kinote" ] || [ "$WHOAMI" == "aguespjo" ] ; then PATHCOLOR='\[\033[01;34m\]' PROMPTCHR='\[\033[00;34m\]%' SHOWUSER="" else PATHCOLOR='\[\033[01;34m\]' PROMPTCHR='\[\033[01;34m\]%' SHOWUSER="$WHOAMI@" fi case "$(hostname)" in "surtr") HOSTCOLOR='\[\033[00;36m\]';; "grani") HOSTCOLOR='\[\033[01;30m\]';; "ymir") HOSTCOLOR='\[\033[01;31m\]';; "niflheim") HOSTCOLOR='\[\033[00;34m\]';; "nbiku1352") HOSTCOLOR='\[\033[01;32m\]';; "fafnir") HOSTCOLOR='\[\033[00;31m\]';; "pumuckl") HOSTCOLOR='\[\033[01;31m\]';; "nothung") HOSTCOLOR='\[\033[00;36m\]';; "mime") HOSTCOLOR='\[\033[01;36m\]';; "loge") HOSTCOLOR='\[\033[00;35m\]';; "freki") HOSTCOLOR='\[\033[38;5;38m\]';; *) HOSTCOLOR='\[\033[00;32m\]';; esac CERRAR='\[\033[00m\]' export GIT_PS1_SHOWDIRTYSTATE=1 #export GIT_PS1_SHOWCOLORHINTS=1 if [[ "$INSIDE_EMACS" = 'vterm' ]]; then function vterm_printf(){ if [ -n "$TMUX" ]; then # tell tmux to pass the escape sequences through # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) printf "\ePtmux;\e\e]%s\007\e\\" "$1" elif [ "${TERM%%-*}" = "screen" ]; then # GNU screen (screen, screen-256color, screen-256color-bce) printf "\eP\e]%s\007\e\\" "$1" else printf "\e]%s\e\\" "$1" fi } function clear(){ vterm_printf "51;Evterm-clear-scrollback"; tput clear; } vterm_prompt_end(){ vterm_printf "51;A$(whoami)@$(hostname):$(pwd)" } PS1=$PS1'\[$(vterm_prompt_end)\]' fi # Export prompt set_bash_prompt() { # schroot indicator CHR="${SCHROOT_CHROOT_NAME:+(\[\033[01;32m\]$SCHROOT_CHROOT_NAME\[\033[00m\]) }" # virtualenv indicator VENV="${VIRTUAL_ENV:+(\[\033[00;32m\]venv\[\033[00m\])}" # Show only last two dirs in path LAST_TWO_DIRS=$(pwd | sed s_"$HOME"_~_ |rev| awk -F / '{print $1,"/",$2}' | rev | sed s_\ /\ _/_ | sed s_^/~_~_) # Git prompt GITPS1=$(__git_ps1 ':%s') if [[ "$GITPS1" == *\ * ]]; then GITPSCOLOR='\[\033[01;31m\]' else GITPSCOLOR='\[\033[01;35m\]' fi # Yocto BUILDDIR if [[ x"$BUILDDIR" != x"" ]]; then BUILDPS1='\[\033[01;31m\](build)' else BUILDPS1="" fi # Prompt PS1="$CHR$VENV$HOSTCOLOR$SHOWUSER\\h$CERRAR $BUILDPS1$PATHCOLOR$LAST_TWO_DIRS$CERRAR$GITPSCOLOR$GITPS1$CERRAR $PROMPTCHR $CERRAR" if [[ "$INSIDE_EMACS" = 'vterm' ]]; then PS1=$PS1'\[$(vterm_prompt_end)\]' fi } PROMPT_COMMAND=set_bash_prompt # vim: set ts=8 sts=8 sw=8 noexpandtab :