File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,14 +35,17 @@ join_by() { local IFS="$1"; shift; echo "$*"; }
3535_copy () {
3636 echo
3737 read -q ans? " Copy to clipboard? "
38+ if [ " $ans " = n ]; then
39+ _cleanup 1
40+ return 0
41+ fi
3842 _cleanup
3943 [ " $ans " = n ] && return 0
4044 command -v xc & > /dev/null || return 1
4145 printf " ${1: gs/%/%% } " | xc && echo " Copied!"
4246}
4347
4448show () {
45- echo
4649 local list=" $1 "
4750 local c=` echo -E " $list " | wc -l`
4851 if (( $c > 1 )) ; then
@@ -56,20 +59,35 @@ show() {
5659 fi
5760}
5861
62+ # Clean this line and $1 lines above.
5963_cleanup () {
6064 printf " \r[K"
65+
66+ local i=${1:- 0}
67+ while (( "$i " > 0 )) ; do
68+ printf " [A\r[K"
69+ i=$(( $i - 1 ))
70+ done
6171}
6272
6373_memo_get () {
6474 check_memo
6575 check gpg
6676
77+ local list
6778 if (( ! $# )) ; then
6879 local list=(` gpg -qd $memo | cut -d' ' -f1` )
6980 echo
7081 echo ${list[@]}
7182 elif (( $# == 1 )) ; then
72- local list=" ` gpg -qd $memo | grep -iE ^$1 ` "
83+ # In case it shortcuts in a fail-loop:
84+ # gpg-connect-agent reloadagent /bye
85+ list=" ` gpg -qd --pinentry-mode error $memo 2> /dev/null | grep -iE ^$1 ` "
86+ if [ $? != 0 ]; then
87+ list=" ` gpg -qd $memo | grep -iE ^$1 ` "
88+ [ $? != 0 ] && exit 1
89+ _cleanup 2
90+ fi
7391 show " $list "
7492 else
7593 local q=` join_by \| $* `
You can’t perform that action at this time.
0 commit comments