diff options
-rw-r--r-- | 11_Colors.zsh | 2 | ||||
-rw-r--r-- | 12_Prompts.zsh | 31 |
2 files changed, 25 insertions, 8 deletions
diff --git a/11_Colors.zsh b/11_Colors.zsh index 697a2e9..d9b1e8f 100644 --- a/11_Colors.zsh +++ b/11_Colors.zsh @@ -79,6 +79,8 @@ set_prompt_colors () mail_colors[unread]="$color[yellow];$color[bold]" # mail received mail_colors[listes]="$my_generic;$color[bold]" # less important mail received + prompt_colors[agents]="$prompt_colors[bold_generic]" + prompt_colors[up_to_date]="$my_generic" # up-to-date prompt_colors[not_up_to_date]="$color[green];$color[bold]" # not up to date prompt_colors[to_be_commited]="$color[yellow];$color[bold]" # changes in cache diff --git a/12_Prompts.zsh b/12_Prompts.zsh index d8c8730..88bdef8 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -22,6 +22,8 @@ set_prompt_colors $prompt_colors[generic] # precmd : avant d'afficher le prompt # +SEPARATOR=$C_$prompt_colors[bar]$_C"-" + expand_text() { # strips the %{...%} @@ -69,7 +71,7 @@ set_prompt_date() { # Date [ "$DEBUG" = "yes" ] && echo -n " Date..." - DATE=$C_$prompt_colors[braces]$_C"[ "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" ]"$C_$prompt_colors[bar]$_C"-" + DATE=$C_$prompt_colors[braces]$_C"[ "$C_$prompt_colors[date]$_C"%D{%a-%d-%b-%Y %H:%M:%S}"$C_$prompt_colors[braces]$_C" ]"$SEPARATOR DATEEXPAND=$(expand_text "$DATE") DATESIZE=${#DATEEXPAND} [ "$DEBUG" = "yes" ] && echo @@ -78,10 +80,10 @@ set_prompt_date() update_prompt() { # Error - error=$(print -Pn "%(?;;-%?)") + error=$(print -Pn "%(?;;-%?)") ## MUST BE the first operation else we lose the error code... [ "$DEBUG" = "yes" ] && echo -n " Error code..." ERRORSIZE=${#error} - ERROR="%(?;;"$C_$prompt_colors[bar]$_C"-"$C_$prompt_colors[error]$_C"%?)" + ERROR="%(?;;"$SEPARATOR$C_$prompt_colors[error]$_C"%?)" [ "$DEBUG" = "yes" ] && echo [ "$DEBUG" = "yes" ] && echo -n " Term title..." @@ -90,6 +92,19 @@ update_prompt() [ "$DEBUG" = "yes" ] && echo set_prompt_date + + # GPG/SSH agents + AGENTS="" + if [ "$SSH_AGENT_PID" -gt 0 -a "`strings /proc/$SSH_AGENT_PID/cmdline | head -n1`" = "ssh-agent" ] + then + AGENTS=$SEPARATOR$C_$prompt_colors[agents]$_C"★" + fi + if [ "$GPG_AGENT_INFO" != "" -a "`strings /proc/$(echo $GPG_AGENT_INFO | cut -d: -f2)/cmdline | head -n1`" = "gpg-agent" ] + then + AGENTS=$AGENTS$SEPARATOR$C_$prompt_colors[agents]$_C"☆" + fi + AGENTSSIZE=$(expand_text $AGENTS) + AGENTSSIZE=$#AGENTSSIZE # Mailcheck [ "$DEBUG" = "yes" ] && echo -n " Mails..." @@ -113,7 +128,7 @@ update_prompt() if [ $BATTERYCHARGING -gt 0 ] then BATTERY="$C_$battery_colors[charging]$_C"$BATTERY - BATTERY="$C_$prompt_colors[bar]$_C"-"$BATTERY" + BATTERY="$SEPARATOR$BATTERY" else if [ $BATTERYCHARGING -lt 0 ] then @@ -123,14 +138,14 @@ update_prompt() else BATTERY="$C_$battery_colors[uncharging]$_C"$BATTERY fi - BATTERY="$C_$prompt_colors[bar]$_C"-"$BATTERY" + BATTERY="$SEPARATOR$BATTERY" else ## Battery full BATTERY=$(grep "^AC Power" /proc/pmu/info | cut -c26) if [ $BATTERY -ne 0 ] then BATTERY="⚡" - BATTERY="$C_$prompt_colors[bar]$_C"-"$BATTERY" + BATTERY="$SEPARATOR$BATTERY" BATTERYSIZE=2 else BATTERY="" @@ -147,7 +162,7 @@ update_prompt() [ "$DEBUG" = "yes" ] && echo -n " Horizontal bar..." # First line of prompt, calculation of the remaining place - spaceleft=$(($COLUMNS - $ERRORSIZE - $MAILSTATSIZE - $DATESIZE - $BATTERYSIZE)) + spaceleft=$(($COLUMNS - $ERRORSIZE - $AGENTSSIZE - $MAILSTATSIZE - $DATESIZE - $BATTERYSIZE)) unset HBAR for h in {1..$spaceleft} @@ -230,7 +245,7 @@ redisplay_prompt () # Affiche l'user, l'host, le tty et le pwd. Rien que ça... # Note que pour le pwd, on n'affiche que les 4 derniers dossiers pour éviter # de pourrir le fenêtre de terminal avec un prompt à rallonge. - PS1="$MAILSTAT""$ERROR""$BATTERY"$C_$prompt_colors[bar]$_C"$HBAR""$DATE + PS1="$AGENTS""$MAILSTAT""$ERROR""$BATTERY"$C_$prompt_colors[bar]$_C"$HBAR""$DATE "$C_$prompt_colors[user]$_C"%n"$C_$prompt_colors[arob]$_C"@"$C_$prompt_colors[host]$_C"%m $CURDIR$SVNREV$GITBRANCH "$C_$prompt_colors[dies]$_C"%#"$C_$prompt_colors[cmd]$_C" " } |