60 lines
1.4 KiB
Bash
60 lines
1.4 KiB
Bash
function _ps_name_and_server {
|
|
echo "`whoami`@`hostname -s`"
|
|
}
|
|
|
|
function _ps_git_branch_and_status {
|
|
_GIT_STATUS="`git status --porcelain 2>/dev/null`"
|
|
if [ $? -eq 0 ];then
|
|
_GIT_DIRTY=""
|
|
if [ "$_GIT_STATUS" != "" ];then
|
|
_GIT_DIRTY="*"
|
|
fi
|
|
_GIT_BRANCH="`git branch --no-color | grep '*' | cut -d ' ' -f 2`"
|
|
|
|
echo " $_GIT_BRANCH$_GIT_DIRTY"
|
|
else
|
|
echo ""
|
|
fi
|
|
}
|
|
|
|
function _ps_virtual_env {
|
|
if [ "$VIRTUAL_ENV" != "" ];then
|
|
echo " `basename "$VIRTUAL_ENV"`"
|
|
fi
|
|
}
|
|
|
|
function _ps_prompt {
|
|
# regular colors
|
|
local K="\[\033[0;30m\]" # black
|
|
local R="\[\033[0;31m\]" # red
|
|
local G="\[\033[0;32m\]" # green
|
|
local Y="\[\033[0;33m\]" # yellow
|
|
local B="\[\033[0;34m\]" # blue
|
|
local M="\[\033[0;35m\]" # magenta
|
|
local C="\[\033[0;36m\]" # cyan
|
|
local W="\[\033[0;37m\]" # white
|
|
|
|
# emphasized (bolded) colors
|
|
local BK="\[\033[1;30m\]"
|
|
local BR="\[\033[1;31m\]"
|
|
local BG="\[\033[1;32m\]"
|
|
local BY="\[\033[1;33m\]"
|
|
local BB="\[\033[1;34m\]"
|
|
local BM="\[\033[1;35m\]"
|
|
local BC="\[\033[1;36m\]"
|
|
local BW="\[\033[1;37m\]"
|
|
|
|
# reset
|
|
local RESET="\[\033[0;37m\]"
|
|
|
|
local HOST="$RESET@$BB\h"
|
|
if [ -z "$SSH_CONNECTION" ];then
|
|
HOST=""
|
|
fi
|
|
|
|
echo "$Y\u$HOST $BG\w$C$(_ps_virtual_env)$M$(_ps_git_branch_and_status) $Y\$$RESET "
|
|
}
|
|
|
|
PS1=$(_ps_prompt)
|
|
PROMPT_COMMAND='PS1=$(_ps_prompt)'
|