more sleek colorize() for bashrc
This commit is contained in:
parent
422cfdd6f4
commit
c410a8a0a2
1 changed files with 5 additions and 9 deletions
14
bashrc
14
bashrc
|
@ -16,19 +16,15 @@ export LS_COLORS='no=00:fi=00:di=34:ow=34;40:ln=35:pi=30;44:so=35;44:do=35;44:bd
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ prompt
|
# {{{ prompt
|
||||||
colorize() {
|
colorize() {
|
||||||
typeset prompt="$1"; shift
|
typeset escs prompt="$1" color_nr="$2"; shift 2
|
||||||
typeset color_nr="$1"; shift
|
((prompt)) && escs='\[\e[38;5;%sm\]%s\[\e[39m\]' || escs='\e[38;5;%sm%s\e[39m'
|
||||||
if ((prompt)); then
|
printf "$escs" "$color_nr" "$*"
|
||||||
printf '\[\e[38;5;%sm\]%s\[\e[39m\]' "$color_nr" "$*"
|
|
||||||
else
|
|
||||||
printf '\e[38;5;%sm%s\e[39m' "$color_nr" "$*"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
prompt_command() {
|
prompt_command() {
|
||||||
typeset cwd=$(colorize 1 8 "$(pwd)")
|
typeset cwd=$(colorize 1 8 "$(pwd)")
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
(screen*) printf '\033k%s\033\' "${HOSTNAME%%.*}";;
|
(screen*) printf '\ek%s\e\' "${HOSTNAME%%.*}";;
|
||||||
(*) printf '\033]0;%s\007' "${HOSTNAME%%.*}";;
|
(*) printf '\e]0;%s\a' "${HOSTNAME%%.*}";;
|
||||||
esac
|
esac
|
||||||
PS1="[ bash-\\v | $ps_user $HOSTNAME:$cwd ]\\n$ps_bang "
|
PS1="[ bash-\\v | $ps_user $HOSTNAME:$cwd ]\\n$ps_bang "
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue