diff --git a/bin/Makefile b/bin/Makefile index 57ac756..bcd7ff7 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -16,7 +16,7 @@ PREFIX = $(HOME) MANPREFIX = $(PREFIX)/local BIN = ZZZ browser credentials fetch flac2ogg imgresize invidious \ riot-web-ui rfcopen screenshot sekrit tor-browser \ - w3m-copy-link xsekrit + w3m-copy-link MAN1 = sekrit.1 all: $(BIN) diff --git a/bin/credentials.sh b/bin/credentials.sh index 6836604..1776c42 100644 --- a/bin/credentials.sh +++ b/bin/credentials.sh @@ -12,7 +12,11 @@ usage() { - printf "Usage: %s [-2pu] service\n" "${0##*/}" >&2 + cat - <<. >&2 +Usage: + ${0##*/} [-2pu] service + ${0##*/} -r key +. exit 1 } @@ -86,15 +90,28 @@ get_service() [ $sfa = yes ] && get_2fa "$service" } +get_raw() +{ + key=$1 + + sekrit has "$key" || err "Unknown key \"$key\"." + + printf "%s" "$key" + sekrit get "$key" | clip && printf "\n" +} + sfa=no pass=no +raw=no user=no -while getopts 2pu flag; do +while getopts 2pru flag; do case $flag in 2) sfa=check ;; p) pass=check ;; + r) raw=yes + ;; u) user=check ;; *) usage @@ -106,4 +123,11 @@ shift $(($OPTIND - 1)) [ $# -eq 1 ] && [ -n "$1" ] || usage key=$1 -get_service "$key" $user $pass $sfa +if [ $raw = yes ]; then + if [ $sfa != no ] || [ $pass != no ] || [ $user != no ]; then + err "-r is mutually exclusive with -2pu." + fi + get_raw "$key" +else + get_service "$key" $user $pass $sfa +fi diff --git a/bin/xsekrit.sh b/bin/xsekrit.sh deleted file mode 100644 index 183d62d..0000000 --- a/bin/xsekrit.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# xsekrit -# Written in 2019 by Lucas -# CC0 1.0 Universal/Public domain - No rights reserved -# -# To the extent possible under law, the author(s) have dedicated all -# copyright and related and neighboring rights to this software to the -# public domain worldwide. This software is distributed without any -# warranty. You should have received a copy of the CC0 Public Domain -# Dedication along with this software. If not, see -# . - -usage() -{ - printf "Usage: %s key\n" "${0##*/}" >&2 - exit 1 -} - -err() -{ - printf "%s: %s\n" "${0##*/}" "$*" >&2 - exit 1 -} - -[ $# -eq 1 ] && [ -n "$1" ] || usage -sekrit has "$1" || err "Unknown key \"$1\"." -sekrit get "$1" | xclip -q -r -l 1 -sel clip 2>/dev/null