From 0df98183144ad57380133807b6976aaaa7b1ad53 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Tue, 14 Dec 2021 08:55:35 +0100 Subject: [PATCH] added status for loaded ssh keys --- .bashrc | 11 ----------- .functions/ps1.sh | 6 ++++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.bashrc b/.bashrc index 0905b9b..3c07485 100644 --- a/.bashrc +++ b/.bashrc @@ -5,17 +5,6 @@ export HISTFILESIZE=-1 export EDITOR="vim" # used by systemd user unit file ssh-agent in ~/.config/systemd/user/ssh-agent.service -#[Unit] -#Description=SSH key agent -# -#[Service] -#Type=simple -#Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket -#ExecStart=/usr/bin/ssh-agent -D -a $SSH_AUTH_SOCK -# -#[Install] -#WantedBy=default.target -# #Also add "AddKeysToAgent yes" to ~/.ssh/config export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket" diff --git a/.functions/ps1.sh b/.functions/ps1.sh index 5e4b053..5fcdab0 100644 --- a/.functions/ps1.sh +++ b/.functions/ps1.sh @@ -33,6 +33,7 @@ function bash_ps1 () { local PS1_COLOR_TODO="${PS1_COLOR_TODO:-\[\033[1;30m\]\[\033[43m\]}" local PS1_COLOR_DOTF="${PS1_COLOR_DOTF:-\[\033[1;37m\]\[\033[45m\]}" local PS1_COLOR_PASS="${PS1_COLOR_PASS:-\[\033[0;30m\]\[\033[47m\]}" + local PS1_COLOR_SSH="${PS1_COLOR_SSH:-\[\033[0;37m\]\[\033[44m\]}" local CURRENT_CONTEXT="" @@ -72,6 +73,11 @@ function bash_ps1 () { fi fi + if type -t ssh-add > /dev/null;then + if [[ "$(ssh-add -L | grep -E -c '^ssh')" == "0" ]];then + STATUS="${STATUS}${PS1_COLOR_SSH}s" + fi + fi if [[ $(type -t todo_status) == function ]] && [[ "$(todo_status)" == "YES" ]];then STATUS="${STATUS}${PS1_COLOR_TODO}T"