summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2009-01-30 10:53:10 +0100
committerHugues Hiegel <hugues@hiegel.fr>2009-01-30 10:53:10 +0100
commitbd608f7f0273b19105feecc7b37a5bb24b74fe9e (patch)
tree95d43c028f600beda7da49713fcd208022f39943
parent761ac185d4eedcba566da3e1429a94ccd1857270 (diff)
[PROMPT] Added a GPG/SSH agent manager :-)
-rw-r--r--11_Colors.zsh2
-rw-r--r--12_Prompts.zsh17
2 files changed, 17 insertions, 2 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 d1801fd..5b1ea2d 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -92,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..."
@@ -153,7 +166,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}
@@ -236,7 +249,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" "
}