From 1697c66240bc9d7b85e50f500ac6704f8e69bf33 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 7 Jun 2012 15:25:57 +0200 Subject: [Debug] better debug managment --- 12_Prompts.zsh | 51 +++++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) (limited to '12_Prompts.zsh') diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 20a4f94..ab0711b 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -69,6 +69,7 @@ __hbar() { if [ $COLUMNS != $_COLUMNS_OLD ] then + __debug -n " Horizontal bar..." _COLUMNS_OLD=$COLUMNS unset HBAR HBAR=$C_$_prompt_colors[bar]$_C$T_ @@ -77,6 +78,7 @@ __hbar() HBAR=${HBAR}$_tq_ done HBAR=$HBAR$_T + __debug fi } @@ -122,47 +124,38 @@ __set_prompt_date() end=${${1:+$_tm_}:-$_tl_} # Date - [ "$DEBUG" = "yes" ] && echo -n " Date..." >&2 - 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}$_tq_"$_T + __debug -n " Date..." + DATE=$C_$_prompt_colors[braces]$_C$T_"${begin}"$_T" "$C_$_date_colors[${1:-normal}]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$_prompt_colors[braces]$_C" "$C_$_prompt_colors[bar]$_C$T_"${end}$_tq_"$_T DATEEXPAND=$(__expand_text "$DATE") DATESIZE=${#DATEEXPAND} - [ "$DEBUG" = "yes" ] && echo >&2 + __debug } __update_prompt_elements() { - - [ "$DEBUG" = "yes" ] && echo -n " Term title..." >&2 - # Flush the term title __term_title - [ "$DEBUG" = "yes" ] && echo >&2 - __set_prompt_date - - [ "$DEBUG" = "yes" ] && echo -n " Horizontal bar..." >&2 __hbar - [ "$DEBUG" = "yes" ] && echo >&2 - __vcsbranch - } __error_code () { # Error - [ "$DEBUG" = "yes" ] && echo -n " Error code..." >&2 + __debug -n " Error code..." echo ${ERROR:+$C_$_prompt_colors[error]$_C$ERROR} - [ "$DEBUG" = "yes" ] && echo >&2 + __debug } PS1_TASKBAR+=(__error_code) __ssh_gpg_agents () { - [ "$DEBUG" = "yes" ] && echo -n " Agents..." >&2 + __debug -n " Agents..." # GPG/SSH agents AGENTS="" - [ "$DEBUG" = "yes" ] && echo && echo -n " ......SSH" >&2 + __debug + __debug -n " ......SSH" # Check ssh-agent only if the env socket has been set and is accessible if [ -S "$SSH_AUTH_SOCK" ] then @@ -198,7 +191,8 @@ __ssh_gpg_agents () fi fi - [ "$DEBUG" = "yes" ] && echo >&2 && echo -n " ......GPG" >&2 + __debug + __debug -n " ......GPG" GPG_AGENT_PID="$(echo $GPG_AGENT_INFO | cut -d: -f2)" if [ "$GPG_AGENT_PID" != "" -a -e /proc/$GPG_AGENT_PID/cmdline ] then @@ -208,7 +202,7 @@ __ssh_gpg_agents () AGENTS=$AGENTS$C_$_agent_colors[$AGENTCOLOR]$_C${GPG_AGENT_RUNNING:-⚡} fi fi - [ "$DEBUG" = "yes" ] && echo >&2 + __debug echo $AGENTS } @@ -220,18 +214,19 @@ __vcsbranch () # get cvs tag # CVSTAG="" - [ "$DEBUG" = "yes" ] && echo -n " CVS status..." >&2 if [ -d CVS ] then + __debug -n " CVS status..." CVSTAG=$(test -e CVS/Tag && cat CVS/Tag || basename $(cat CVS/Root 2>&- || echo "HEAD") ) CVSTAG=${CVSTAG:+ $C_$_gcl_colors[uptodate]$_C$CVSTAG} + __debug fi if [ -d .svn ] then # get svn status # - [ "$DEBUG" = "yes" ] && echo -n " SVN status..." >&2 + __debug -n " SVN status..." SVNREV=$(LC_ALL=C svn info 2>&- $PWD | awk '/^Revision: / {print $2}') SVNREVSIZE=${#${SVNREV:+ r$SVNREV}} if [ "$SVNREV" != "" ] @@ -243,29 +238,25 @@ __vcsbranch () fi fi SVNREV=${SVNREV:+$C_$_prompt_colors[doubledot]$_C $C_$SVNSTATUS$_C"r"$SVNREV} - [ "$DEBUG" = "yes" ] && echo >&2 + __debug fi # get hg status - [ "$DEBUG" = "yes" ] && echo -n " HG status..." >&2 HGBRANCH=$(__get_gcl_branch hg) [ ! -z "$HGBRANCH" ] && HGBRANCH=" "$HGBRANCH - [ "$DEBUG" = "yes" ] && echo >&2 # get git status # - [ "$DEBUG" = "yes" ] && echo -n " GIT status..." >&2 GITBRANCH=$(__get_gcl_branch git) GITBRANCHSIZE=${#GITBRANCH} [ $GITBRANCHSIZE -gt 0 ] && GITBRANCHSIZE=$(($GITBRANCHSIZE)) - [ "$DEBUG" = "yes" ] && echo >&2 - [ "$DEBUG" = "yes" ] && echo -n " Path..." >&2 + __debug -n " Path..." MY_PATH="%(!.%d.%~)" PATHSIZE=$(print -Pn $MY_PATH) PATHSIZE=${#PATHSIZE} - [ "$DEBUG" = "yes" ] && echo >&2 - [ "$DEBUG" = "yes" ] && echo -n " Resize path / gitbranch..." >&2 + __debug + __debug -n " Resize path / gitbranch..." spaceleft=`__expand_text "%n@%m${DISPLAY:+($DISPLAY)}$COMPILATION $ ls -laCdtrux $DATE"` spaceleft=$(($COLUMNS - ${#spaceleft})) #minimalpathsize=`print -Pn "../%1~"` @@ -297,7 +288,7 @@ __vcsbranch () GITBRANCH=$C_$_prompt_colors[soft_generic]$_C${${GITBRANCH/→/$C_"$(__get_git_status)"$_C}/←/$C_$_prompt_colors[soft_generic]$_C}"$(__get_guilt_series)$C_$color[none]$_C" fi CURDIR="$C_$_prompt_colors[path]$_C%`echo $spaceleft`<..<"$MY_PATH"%<<$C_$color[none]$_C" - [ "$DEBUG" = "yes" ] && echo >&2 + __debug VCSBRANCH=$CVSTAG$SVNREV$GITBRANCH$HGBRANCH -- cgit v1.2.3