summaryrefslogtreecommitdiff
path: root/12_Prompts.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2009-01-30 16:39:25 +0100
committerHugues Hiegel <hugues@hiegel.fr>2009-01-30 16:39:25 +0100
commit4a5b97a865f614b4aebf93a2d04bb6616c7d864d (patch)
treee221256761c581459e2be034e045c861e642c52c /12_Prompts.zsh
parent2e095258f79a96b4ba2c495c244a58fd9e9638ad (diff)
[PROMPT] SSH agent key listing, and GnuPG agent better managment
Diffstat (limited to '12_Prompts.zsh')
-rw-r--r--12_Prompts.zsh24
1 files changed, 17 insertions, 7 deletions
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index 8a8d5d1..364c22c 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -111,16 +111,26 @@ update_prompt()
AGENTS=""
if [ "$SSH_AGENT_PID" -gt 0 -a -e /proc/$SSH_AGENT_PID/cmdline ]
then
- [ "`strings /proc/$SSH_AGENT_PID/cmdline | head -n1`" = "ssh-agent" ] && \
- AGENTS=$C_$prompt_colors[agents]$_C"★"
+ if [ "`strings /proc/$SSH_AGENT_PID/cmdline | head -n1`" = "ssh-agent" ]
+ then
+ ## We have a running ssh agent
+ # get list of keys
+ if [ "$( ssh-add -l | grep "^[[:digit:]]\+ \([[:digit:]a-f]\{2\}:\)\{15\}[[:digit:]a-f]\{2\} .* (.*)$" )" != "" ]
+ then
+ AGENTCOLOR="has_keys"
+ else
+ AGENTCOLOR="empty"
+ fi
+ AGENTS=$C_$agent_colors[$AGENTCOLOR]$_C"★"
+ fi
fi
- if [ "$GPG_AGENT_INFO" != "" ]
+ GPG_AGENT_PID="$(echo $GPG_AGENT_INFO | cut -d: -f2)"
+ if [ "$GPG_AGENT_PID" != "" -a -e /proc/$GPG_AGENT_PID/cmdline ]
then
- GPG_AGENT_PID="$(echo $GPG_AGENT_INFO | cut -d: -f2)"
- if [ -e /proc/$GPG_AGENT_PID/cmdline ]
+ if [ "`strings /proc/$GPG_AGENT_PID/cmdline | head -n1`" = "gpg-agent" ]
then
- [ "`strings /proc/$GPG_AGENT_PID/cmdline | head -n1`" = "gpg-agent" ] && \
- AGENTS=$AGENTS$C_$prompt_colors[agents]$_C"☆"
+ AGENTCOLOR="has_keys"
+ AGENTS=$AGENTS$C_$agent_colors[$AGENTCOLOR]$_C"☆"
fi
fi
AGENTS=${AGENTS:+$SEPARATOR$AGENTS}