From b7b42704a331475392c7ce262c1a3cf7951eb61b Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 17 Jan 2012 20:35:34 +0100 Subject: Manages termcaps only on good terminals.. --- 01_Functions.zsh | 12 ++++++------ 10_Environment.zsh | 16 +++++++++++++--- 12_Prompts.zsh | 18 +++++++++--------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/01_Functions.zsh b/01_Functions.zsh index 4c2f86b..1431785 100644 --- a/01_Functions.zsh +++ b/01_Functions.zsh @@ -48,7 +48,7 @@ term_title() for word in ${=@} ; command[$#command]=$word if [ "$command[0]" = "fg" ] then - lastjob=$(ps ft `tty` | grep "[0-9]\+[[:blank:]]\+`tty | sed 's/\/dev\///'`[[:blank:]]\+T.\? \+.:.. \\\_ " | tail -n1 | cut -c32-) + lastjob=$(ps t `tty` | grep "[0-9]\+[[:blank:]]\+`tty | sed 's/\/dev\///'`[[:blank:]]\+T.\? \+.:.. \\\_ " | tail -n1 | cut -c32-) set "$lastjob" fi if [ "$command[0]" = "screen" -o "$command[0]" = "tmux" ] @@ -99,18 +99,18 @@ preprint() local my_color i my_color=${2-"$prompt_colors[generic]"} - hbar=$termcap[as] + hbar=$T_ for i in {1..$((74 - ${#1} - 5))} do - hbar=${hbar}q + hbar=${hbar}$_t_q done - hbar=${hbar}$termcap[ae] + hbar=${hbar}$_T[ae] if [ "$1" != "" ] then - print -Pn "${C_}$my_color;1${_C}${hbar}$termcap[as]u$termcap[ae]${C_}0;$my_color${_C} $1 ${C_}0;$my_color;1${_C}$termcap[as]tq$termcap[ae]\r${C_}0${_C}" + print -Pn "${C_}$my_color;1${_C}${hbar}$_t_u${C_}0;$my_color${_C} $1 ${C_}0;$my_color;1${_C}$_t_t$_t_q\r${C_}0${_C}" else - print -Pn "${C_}$my_color;1${_C}${hbar}-----${C_}0${_C}" + print -Pn "${C_}$my_color;1${_C}${hbar}$_t_q$_t_q$_t_q$_t_q$_t_q${C_}0${_C}" fi } diff --git a/10_Environment.zsh b/10_Environment.zsh index e84c623..4d41f4a 100644 --- a/10_Environment.zsh +++ b/10_Environment.zsh @@ -25,8 +25,18 @@ c_='['$color[none]";" _c=m C_="%{$c_" _C="$_c%}" -T_=$termcap[as] -_T=$termcap[ae] + +unset _t_ +[ $TERM = "urxvt" ] && _t_=yes +T_=${_t_:+$termcap[as]} +_T=${_t_:+$termcap[ae]} +_t_q=${${_t_:+q}:--} +_t_j=${${_t_:+j}:-[} +_t_k=${${_t_:+k}:-[} +_t_l=${${_t_:+l}:-]} +_t_m=${${_t_:+m}:-]} +_t_t=${${_t_:+t}:-]} +_t_u=${${_t_:+u}:-]} # I hate kik00l0l colorized prompts, so I'm using a way to # give a dominant color for each part of the prompt, each of @@ -77,7 +87,7 @@ HISTSIZE=$(( $SAVEHIST * 1.10 )) export GPG_TTY=`tty` # YeahConsole.. -if ( ps fx | grep $$ -B1 | grep -q yeahconsole ) +if ( ps x | grep $$ -B1 | grep -q yeahconsole ) then YEAHCONSOLE=true fi diff --git a/12_Prompts.zsh b/12_Prompts.zsh index f2f82a5..fd0f61f 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -35,7 +35,7 @@ set_prompt_colors expand_text() { # strips the %{...%} and newlines characters - print -Pn -- "$(echo $@ | tr -d '\n' | sed 's/%{[^(%})]*%}//g;s/'$termcap[ae]'//g;s/'$termcap[as]'//g')" + print -Pn -- "$(echo $@ | tr -d '\n' | sed 's/%{[^(%})]*%}//g;s/'$T_'//g;s/'$_T'//g')" } preexec () @@ -51,7 +51,7 @@ preexec () HBAR=$T_ for h in {1..$spaceleft} do - HBAR=${HBAR}q + HBAR=${HBAR}$_t_q done HBAR=$HBAR$_T redefine_prompt @@ -67,12 +67,12 @@ preexec () set_prompt_date() { - begin=${${1:+j}:-k} - end=${${1:+m}:-l} + begin=${${1:+$_t_j}:-$_t_k} + end=${${1:+$_t_m}:-$_t_l} # Date [ "$DEBUG" = "yes" ] && echo -n " Date..." - DATE=$C_$prompt_colors[braces]$_C$T_"${begin}"$_T" "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" "$C_$prompt_colors[bar]$_C$T_"${end}q"$_T + DATE=$C_$prompt_colors[braces]$_C$T_"${begin}"$_T" "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" "$C_$prompt_colors[bar]$_C$T_"${end}$_t_q"$_T DATEEXPAND=$(expand_text "$DATE") DATESIZE=${#DATEEXPAND} [ "$DEBUG" = "yes" ] && echo @@ -83,7 +83,7 @@ update_prompt_elements() # Error [ "$DEBUG" = "yes" ] && echo -n " Error code..." ERRORSIZE=${#error} - ERROR="%(?;;"$C_$prompt_colors[bar]$_C$T_"q"$_T$C_$prompt_colors[error]$_C"%?)" + ERROR="%(?;;"$C_$prompt_colors[bar]$_C$T_"$_t_q"$_T$C_$prompt_colors[error]$_C"%?)" [ "$DEBUG" = "yes" ] && echo [ "$DEBUG" = "yes" ] && echo -n " Term title..." @@ -148,7 +148,7 @@ update_prompt_elements() AGENTS=$AGENTS$C_$agent_colors[$AGENTCOLOR]$_C${GPG_AGENT_RUNNING:-$( [ $_is_multibyte_compliant ] && echo "⚡" || echo "G" )} fi fi - AGENTS=${AGENTS:+$C_$prompt_colors[bar]$_C$T_"q"$_T$AGENTS} + AGENTS=${AGENTS:+$C_$prompt_colors[bar]$_C$T_"$_t_q"$_T$AGENTS} AGENTSSIZE=$(expand_text $AGENTS) AGENTSSIZE=$#AGENTSSIZE [ "$DEBUG" = "yes" ] && echo @@ -196,7 +196,7 @@ update_prompt_elements() battery[color]="uncharging" fi fi - BATTERY=$C_$prompt_colors[bar]$_C$T_"q"$_T$C_$battery_colors[$battery[color]]$_C"$battery[remains]" + BATTERY=$C_$prompt_colors[bar]$_C$T_"$_t_q"$_T$C_$battery_colors[$battery[color]]$_C"$battery[remains]" unset battery [ "$DEBUG" = "yes" ] && echo @@ -212,7 +212,7 @@ update_prompt_elements() HBAR=$T_ for h in {1..$spaceleft} do - HBAR=$HBAR"q" + HBAR=$HBAR"$_t_q" done HBAR=$HBAR$_T [ "$DEBUG" = "yes" ] && echo -- cgit v1.2.3