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