Skip to content

Commit 77cd141

Browse files
committed
Retry for incorrect password attempts
1 parent 7f018fa commit 77cd141

File tree

6 files changed

+23
-33
lines changed

6 files changed

+23
-33
lines changed

.aliases

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ alias cp="cp -v"
4141
alias mv="mv -v"
4242

4343
# https://gist.github.com/pudquick/29bc95b6c49703992981864e48f8e341
44-
alias brew=~/.local/homebrew/bin/brew
44+
alias brew="~/.local/homebrew/bin/brew"
45+
46+
# View inline images in w3m with iTerm2
47+
alias w3m="w3m -sixel"

.local/bin/,kp

+3-14
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22

33
set -Eeuo pipefail
44

5-
##############################################################################
6-
#
7-
# kpf
8-
# fzf for keepassxc-cli
9-
# (c) Steven Saus 2021
10-
# Licensed under the MIT license
11-
#
12-
# BEFORE RUNNING - two environment variables
13-
# export KPPW="Your KeepassxC password"
14-
# export KPDB=/path/to/keepassxc.kdbx
15-
#
16-
##############################################################################
17-
185
readonly TIMEOUT=${TIMEOUT:-0} # Timeout before clearing the clipboard (default is 10 seconds, set to 0 for unlimited).
196
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
207
FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS:---ansi --exact --multi --no-hscroll}"
@@ -27,8 +14,10 @@ if [ $# -eq 0 ]; then
2714
KPVALUE=$(keepassxc-cli ls --recursive --flatten "${KPDB}" 2> /dev/null < <(echo "${KPPW}") | fzf-tmux ${FZF_DEFAULT_OPTS} --preview="$SCRIPT_NAME {}" )
2815
keepassxc-cli show "${KPDB}" "${KPVALUE}" --show-attachments 2> /dev/null < <(echo "${KPPW}") | bat --highlight-line=1 --language=http --plain
2916
echo -n "TOTP: "
30-
keepassxc-cli show "${KPDB}" "${KPVALUE}" --totp 2> /dev/null < <(echo "${KPPW}")
17+
keepassxc-cli show "${KPDB}" "${KPVALUE}" --totp 2> /dev/null < <(echo "${KPPW}") || echo
3118
keepassxc-cli clip --attribute password "${KPDB}" "${KPVALUE}" "${TIMEOUT}" 2> /dev/null < <(echo "${KPPW}")
3219
else
3320
keepassxc-cli show "${KPDB}" "${1}" 2> /dev/null < <(echo "${KPPW}") | bat --highlight-line=1 --language=http --plain
21+
echo -n "TOTP: "
22+
keepassxc-cli show "${KPDB}" "${1}" --totp 2> /dev/null < <(echo "${KPPW}") || echo
3423
fi

.local/bin/,softwareupdate

-10
This file was deleted.

.local/bin/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
mutt
22
password
33
,balance-checkbook
4-
,mount-fritz
54
,shutdown_raspberrypi
65

.local/bin/.kp.function

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -Eeuo pipefail
44

55
FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS:---ansi --exact --multi --no-hscroll}"
66
readonly HEADER_DB_SELECTION="Choose KeepassXC database:"
7-
readonly HEADER_PASSWORD="Please enter the password for the KeepassX database \"%s\": "
7+
readonly HEADER_PASSWORD="Please enter the password for the KeepassX database \"%s\":"
88

99
export KPDB
1010
export KPPW
@@ -15,9 +15,17 @@ if [ -z "${KPDB+x}" ] || [ ! -f "${KPDB}" ]; then
1515
fi
1616

1717
if [ -z "${KPPW+x}" ]; then
18-
prompt=$(printf "${HEADER_PASSWORD}" "$(basename "${KPDB}")")
19-
IFS= read -r -s -p "${prompt}" KPPW < /dev/tty
20-
keepassxc-cli open "${KPDB}" < <(echo "${KPPW}") 1>/dev/null 2>&1
21-
ret_code=$?
22-
return $ret_code
18+
PROMPT=$(printf "${HEADER_PASSWORD}$(echo $'\nPassword:')" "$(basename "${KPDB}")")
19+
readonly PROMPT
20+
21+
for _ in {1..3}; do
22+
IFS= read -r -s -p "${PROMPT}" KPPW < /dev/tty
23+
keepassxc-cli open "${KPDB}" < <(echo "${KPPW}") 1>/dev/null 2>&1 && ret_code=0 && break || ret_code=$?
24+
printf '\nSorry, try again.\n'
25+
done
26+
27+
if [[ ret_code -ne 0 ]]; then
28+
printf "3 incorrect password attempts"
29+
fi
30+
return "${ret_code}"
2331
fi

.tmux.conf.local

+2-1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ tmux_conf_copy_to_os_clipboard=false
343343
# -- user customizations -------------------------------------------------------
344344
# this is the place to override or undo settings
345345

346+
set-option default-terminal "screen-256color"
347+
346348
# increase history size
347349
#set -g history-limit 10000
348350

@@ -369,7 +371,6 @@ set -g mode-keys vi
369371

370372
# Open default windows
371373
new-session -d -s ssh_tmux
372-
new-window -n emacs -S emacs
373374
new-window -n mutt -S neomutt
374375
new-window -n bash -S
375376

0 commit comments

Comments
 (0)