diff options
author | Stefan Kreutz <mail@skreutz.com> | 2024-01-31 12:03:00 +0100 |
---|---|---|
committer | Stefan Kreutz <mail@skreutz.com> | 2024-01-31 12:03:00 +0100 |
commit | 07bb7b5046add159d1900f60a92da0fe63aed2f1 (patch) | |
tree | eb5a06ec8a6aa54fdb0b404276c1361c017ddeaf | |
parent | f5d2d52764917c9b5a171d8c68a61a13a4be6d88 (diff) | |
download | shellpass-07bb7b5046add159d1900f60a92da0fe63aed2f1.tar |
Add head command
-rw-r--r-- | completion.ksh | 2 | ||||
-rwxr-xr-x | shellpass-ssh.sh | 2 | ||||
-rw-r--r-- | shellpass.1 | 4 | ||||
-rwxr-xr-x | shellpass.ksh | 15 |
4 files changed, 18 insertions, 5 deletions
diff --git a/completion.ksh b/completion.ksh index 190c574..70527a5 100644 --- a/completion.ksh +++ b/completion.ksh @@ -1 +1 @@ -set -A complete_shellpass -- generate show qrencode clip edit +set -A complete_shellpass -- generate show head qrencode clip edit diff --git a/shellpass-ssh.sh b/shellpass-ssh.sh index e0cc38d..1faf01f 100755 --- a/shellpass-ssh.sh +++ b/shellpass-ssh.sh @@ -47,4 +47,4 @@ fi password="$SHELLPASS_SSH_DIR/$( basename "$identity" ).gpg" -shellpass show "$password" +shellpass head "$password" diff --git a/shellpass.1 b/shellpass.1 index a8f0d0e..9658553 100644 --- a/shellpass.1 +++ b/shellpass.1 @@ -42,6 +42,10 @@ Write a random password to the given Print the unencrypted contents of the given .Ar file to standard output. +.It Cm head Ar file +Print the first line of the given +.Ar file +to standard output. .It Cm qrencode Ar file Print a QR code representing the first line of the given .Ar file . diff --git a/shellpass.ksh b/shellpass.ksh index 6f3651a..b986d9d 100755 --- a/shellpass.ksh +++ b/shellpass.ksh @@ -46,6 +46,15 @@ function show { gpg --quiet --decrypt "$file" | "${PAGER:-less}" } +function head { + if [[ $# -ne 1 ]]; then + err_exit "Usage: shellpass head FILE" + fi + file="$1" + + gpg --quiet --decrypt "$file" | command head -n 1 | "${PAGER:-less}" +} + function qrencode { if [[ $# -ne 1 ]]; then err_exit "Usage: shellpass qrencode FILE" @@ -53,7 +62,7 @@ function qrencode { file="$1" gpg --quiet --decrypt "$file" \ - | head -n 1 \ + | command head -n 1 \ | tr -d '\n' \ | ( command qrencode --type=ANSI --strict-version && echo "$file" ) \ | "${PAGER:-less}" @@ -73,7 +82,7 @@ function clip { # shellcheck disable=SC2086 gpg --quiet --decrypt "$file" \ - | head -n 1 \ + | command head -n 1 \ | nohup ${clip_cmd} >/dev/null 2>&1 } @@ -139,7 +148,7 @@ subcommand="$1" shift case "$subcommand" in - generate|show|qrencode|clip|edit) + generate|show|head|qrencode|clip|edit) "$subcommand" "$@" ;; *) |