|
|
@ -2,8 +2,8 @@ |
|
|
|
|
|
|
|
# If not running interactively, don't do anything |
|
|
|
case $- in |
|
|
|
*i*) ;; |
|
|
|
*) return;; |
|
|
|
*i*) ;; |
|
|
|
*) return ;; |
|
|
|
esac |
|
|
|
|
|
|
|
# don't put duplicate lines or lines starting with space in the history. |
|
|
@ -25,7 +25,7 @@ shopt -s checkwinsize |
|
|
|
|
|
|
|
# set a fancy prompt (non-color, unless we know we "want" color) |
|
|
|
case "$TERM" in |
|
|
|
xterm-color|*-256color) |
|
|
|
xterm-color | *-256color) |
|
|
|
color_prompt=yes |
|
|
|
export COLOR_OPTIONS=' --color=auto' |
|
|
|
;; |
|
|
@ -45,7 +45,6 @@ if ! shopt -oq posix; then |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
__prompt_command() { |
|
|
|
local EXIT="$?" # This needs to be first |
|
|
|
|
|
|
@ -59,26 +58,27 @@ __prompt_command() { |
|
|
|
local Mag='\[\e[1;95m\]' |
|
|
|
local Gra='\[\e[1;30m\]' |
|
|
|
|
|
|
|
|
|
|
|
# set xterm title |
|
|
|
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007" |
|
|
|
|
|
|
|
PS1='' |
|
|
|
|
|
|
|
if [[ $container == 'lxc' ]];then |
|
|
|
if [[ $container == 'lxc' ]]; then |
|
|
|
PS1+="${Gra}[LXC:${R}" |
|
|
|
local host=$container_hostname |
|
|
|
case ${host:0:4} in |
|
|
|
'beta') |
|
|
|
PS1+="${Yel}";; |
|
|
|
PS1+="${Yel}" |
|
|
|
;; |
|
|
|
'prod') |
|
|
|
PS1+="${Red}";; |
|
|
|
*) |
|
|
|
PS1+="${Red}" |
|
|
|
;; |
|
|
|
*) ;; |
|
|
|
esac |
|
|
|
PS1+="${host}${Gra}] " |
|
|
|
fi |
|
|
|
|
|
|
|
if [ `id -u` -eq 0 ]; then |
|
|
|
if [ $(id -u) -eq 0 ]; then |
|
|
|
PS1+="${Yel}\u${R}" |
|
|
|
PROMPT='$' |
|
|
|
else |
|
|
@ -90,11 +90,14 @@ __prompt_command() { |
|
|
|
|
|
|
|
case ${HOSTNAME:0:4} in |
|
|
|
'beta') |
|
|
|
PS1+="${Yel}";; |
|
|
|
PS1+="${Yel}" |
|
|
|
;; |
|
|
|
'prod') |
|
|
|
PS1+="${Red}";; |
|
|
|
PS1+="${Red}" |
|
|
|
;; |
|
|
|
*) |
|
|
|
PS1+="${R}";; |
|
|
|
PS1+="${R}" |
|
|
|
;; |
|
|
|
esac |
|
|
|
PS1+="\h" |
|
|
|
|
|
|
@ -106,21 +109,21 @@ __prompt_command() { |
|
|
|
if hash git 2>&-; then |
|
|
|
# git command exists |
|
|
|
|
|
|
|
if git rev-parse --git-dir > /dev/null 2>&1; then |
|
|
|
if git rev-parse --git-dir >/dev/null 2>&1; then |
|
|
|
# current dir is version controlled |
|
|
|
local branch=$(git branch 2> /dev/null | grep -e ^* | cut -d ' ' -f2) |
|
|
|
local branch=$(git branch 2>/dev/null | grep -e ^* | cut -d ' ' -f2) |
|
|
|
PS1+=" ${R}[${Mag}${branch}${R}|" |
|
|
|
|
|
|
|
local tag_release=$(git describe --tags 2> /dev/null | cut -d'-' -f1) |
|
|
|
local tag_release=$(git describe --tags 2>/dev/null | cut -d'-' -f1) |
|
|
|
local dirty=$(git status -s | wc -l) |
|
|
|
if [[ $dirty -ne 0 ]]; then |
|
|
|
PS1+="⚡|${tag_release}${Yel}…$dirty" |
|
|
|
else |
|
|
|
local ahead=$(git rev-list --branches --not --remotes |wc -l) |
|
|
|
local ahead=$(git rev-list --branches --not --remotes | wc -l) |
|
|
|
if [[ $ahead -ne 0 ]]; then |
|
|
|
PS1+="⚡|${tag_release}${Cya}↑${ahead}" |
|
|
|
else |
|
|
|
if [[ -z $tag_release ]];then |
|
|
|
if [[ -z $tag_release ]]; then |
|
|
|
PS1+="${Blu}✔" |
|
|
|
else |
|
|
|
PS1+="${Gre}✔${R}|${Blu}${tag_release}" |
|
|
@ -141,19 +144,17 @@ __prompt_command() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
__vte_osc7 () { |
|
|
|
__vte_osc7() { |
|
|
|
# HINT: special character vte to get TILIX show proper hostname and pwd |
|
|
|
# Use \[...\] around the parts of PS1 that have length 0. |
|
|
|
# https://unix.stackexchange.com/questions/28827/why-is-my-bash-prompt-getting-bugged-when-i-browse-the-history#28828 |
|
|
|
|
|
|
|
VTE_INFO="${HOSTNAME:-}" |
|
|
|
if [[ $container == 'lxc' ]];then |
|
|
|
if [[ $container == 'lxc' ]]; then |
|
|
|
VTE_INFO="${container_hostname}" |
|
|
|
fi |
|
|
|
printf "\[\033]7;file://%s%s\a\]" "${VTE_INFO}" "$(__vte_urlencode "${PWD}")" |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
__vte_urlencode() ( |
|
|
@ -172,10 +173,8 @@ __vte_urlencode() ( |
|
|
|
done |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
PROMPT_COMMAND='__prompt_command' # Func to gen PS1 after CMDs |
|
|
|
|
|
|
|
|
|
|
|
DEBIAN_BASH_DIR=/opt/debian-bash |
|
|
|
|
|
|
|
# You may uncomment the following lines if you want `ls' to be colorized: |
|
|
@ -210,3 +209,8 @@ for i in {/opt,$HOME}/debian-*/tools; do |
|
|
|
PATH=$PATH:$i |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
## Add path for TOOLBOX if any |
|
|
|
if [ -d "/TOOLBOX" ]; then |
|
|
|
PATH=$PATH:/TOOLBOX |
|
|
|
fi |