From cc6bf41082589ef2d12d521f5b7931746740c6bc Mon Sep 17 00:00:00 2001 From: lanxu Date: Sat, 23 Dec 2017 14:08:53 +0200 Subject: [PATCH] Improved lastpass script to re-login in case of errors --- lastpass.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lastpass.sh b/lastpass.sh index 9464ec6..f12873a 100755 --- a/lastpass.sh +++ b/lastpass.sh @@ -1,3 +1,14 @@ #!/bin/sh -lpass ls | grep $1 | awk '{ if (match($0,/\[id: (.*)?\]/,m)) print m[1] }' | xargs lpass show -# --color=always --format="%ai %au %ap" # buggy lpass shit + +# First check if lastpass is correctly initialized +if lpass ls 1>/dev/null 2>&1; then + # success + lpass ls | grep $1 | awk '{ if (match($0,/\[id: (.*)?\]/,m)) print m[1] }' | xargs lpass show + # --color=always --format="%ai %au %ap" # unable to use because lpass is buggy with the formatting +else + # failure + echo -n "Enter login name: " + read loginname + lpass login $loginname +fi +