sekrit: bake in clipboard support with cp subcommand
This commit is contained in:
parent
540f26be40
commit
4657adf4b1
33
bin/sekrit.1
33
bin/sekrit.1
@ -1,6 +1,6 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" sekrit.1
|
.\" sekrit.1
|
||||||
.\" Written in 2018 by Lucas
|
.\" Written in 2018,2020 by Lucas
|
||||||
.\" CC0 1.0 Universal/Public domain - No rights reserved
|
.\" CC0 1.0 Universal/Public domain - No rights reserved
|
||||||
.\"
|
.\"
|
||||||
.\" To the extent possible under law, the author(s) have dedicated all
|
.\" To the extent possible under law, the author(s) have dedicated all
|
||||||
@ -10,28 +10,32 @@
|
|||||||
.\" Dedication along with this software. If not, see
|
.\" Dedication along with this software. If not, see
|
||||||
.\" <http://creativecommons.org/publicdomain/zero/1.0/>.
|
.\" <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
.\"
|
.\"
|
||||||
.Dd September 25, 2018
|
.Dd May 25, 2020
|
||||||
.Dt SEKRIT 1
|
.Dt SEKRIT 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
.Nm sekrit
|
.Nm sekrit
|
||||||
.Nd Secret files manager
|
.Nd Secret files manager
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm sekrit
|
.Nm
|
||||||
.Cm add
|
.Cm add
|
||||||
.Ar key
|
.Ar key
|
||||||
.Op Ar value ...
|
.Op Ar value ...
|
||||||
.Nm sekrit
|
.Nm
|
||||||
|
.Cm cp
|
||||||
|
.Op Fl k
|
||||||
|
.Op key
|
||||||
|
.Nm
|
||||||
.Cm gen
|
.Cm gen
|
||||||
.Op Fl l Ar length
|
.Op Fl l Ar length
|
||||||
.Op Ar chars
|
.Op Ar chars
|
||||||
.Nm sekrit
|
.Nm
|
||||||
.Cm get
|
.Cm get
|
||||||
.Ar key
|
.Ar key
|
||||||
.Nm sekrit
|
.Nm
|
||||||
.Cm has
|
.Cm has
|
||||||
.Ar key
|
.Ar key
|
||||||
.Nm sekrit
|
.Nm
|
||||||
.Cm ls
|
.Cm ls
|
||||||
.Op Ar keys ...
|
.Op Ar keys ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
@ -61,6 +65,14 @@ will read the value from standard input.
|
|||||||
will fail if
|
will fail if
|
||||||
.Ar key
|
.Ar key
|
||||||
already has a value.
|
already has a value.
|
||||||
|
.It Nm Cm cp Oo Fl k Oc Ar key
|
||||||
|
Decrypts the value associated with
|
||||||
|
.Ar key
|
||||||
|
and copies it to the clipboard with
|
||||||
|
.Xr xclip 1 .
|
||||||
|
It removes the last newline unless
|
||||||
|
.Fl k
|
||||||
|
is given.
|
||||||
.It Nm Cm gen Oo Fl l Ar length Oc Op Ar chars
|
.It Nm Cm gen Oo Fl l Ar length Oc Op Ar chars
|
||||||
Outputs a randomly generated sequence.
|
Outputs a randomly generated sequence.
|
||||||
The generated sequence consist of characters
|
The generated sequence consist of characters
|
||||||
@ -122,9 +134,12 @@ in
|
|||||||
.Ar example.com
|
.Ar example.com
|
||||||
you can run
|
you can run
|
||||||
.Bd -literal -offset indent
|
.Bd -literal -offset indent
|
||||||
sekrit get accounts/example.com/user | xclip -l 1 -sel clip -q
|
sekrit cp accounts/example.com/user
|
||||||
sekrit get accounts/example.com/pass | xclip -l 1 -sel clip -q
|
sekrit cp accounts/example.com/pass
|
||||||
.Ed
|
.Ed
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr gpg2 1 ,
|
||||||
|
.Xr xclip 1
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Lucas
|
.An Lucas
|
||||||
.Sh LICENSE
|
.Sh LICENSE
|
||||||
|
@ -30,6 +30,7 @@ usage()
|
|||||||
cat - <<. >&2
|
cat - <<. >&2
|
||||||
Usage:
|
Usage:
|
||||||
${0##*/} add key [value ...]
|
${0##*/} add key [value ...]
|
||||||
|
${0##*/} cp [-k] key
|
||||||
${0##*/} gen [-l length] [chars]
|
${0##*/} gen [-l length] [chars]
|
||||||
${0##*/} get key
|
${0##*/} get key
|
||||||
${0##*/} has key
|
${0##*/} has key
|
||||||
@ -82,6 +83,30 @@ sekrit_add()
|
|||||||
chmod -- 400 "$f"
|
chmod -- 400 "$f"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sekrit_cp()
|
||||||
|
{
|
||||||
|
command -v xclip >/dev/null 2>&1 ||
|
||||||
|
err "xclip required for clipboard support"
|
||||||
|
|
||||||
|
OPTIND=1
|
||||||
|
rmlastnl=-rmlastnl
|
||||||
|
while getopts k flag; do
|
||||||
|
case "$flag" in
|
||||||
|
k) rmlastnl=
|
||||||
|
;;
|
||||||
|
*) usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
|
[ $# -eq 1 ] || usage
|
||||||
|
key=$1
|
||||||
|
|
||||||
|
sekrit_get "$key" |
|
||||||
|
xclip $rmlastnl -loops 1 -quiet -selection clip 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
sekrit_gen()
|
sekrit_gen()
|
||||||
{
|
{
|
||||||
len=43
|
len=43
|
||||||
@ -113,7 +138,7 @@ sekrit_get()
|
|||||||
{
|
{
|
||||||
[ $# -eq 1 ] || usage
|
[ $# -eq 1 ] || usage
|
||||||
key=$1
|
key=$1
|
||||||
check_key "$1"
|
check_key "$key"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
f=$SEKRIT_DIR/$key.gpg
|
f=$SEKRIT_DIR/$key.gpg
|
||||||
@ -125,7 +150,7 @@ sekrit_has()
|
|||||||
{
|
{
|
||||||
[ $# -eq 1 ] || usage
|
[ $# -eq 1 ] || usage
|
||||||
key=$1
|
key=$1
|
||||||
check_key "$1"
|
check_key "$key"
|
||||||
shift
|
shift
|
||||||
|
|
||||||
[ -f "$SEKRIT_DIR/$key.gpg" ]
|
[ -f "$SEKRIT_DIR/$key.gpg" ]
|
||||||
@ -164,6 +189,7 @@ mkdir -p "$SEKRIT_DIR"
|
|||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
add) sekrit_add "$@" ;;
|
add) sekrit_add "$@" ;;
|
||||||
|
cp) sekrit_cp "$@" ;;
|
||||||
gen) sekrit_gen "$@" ;;
|
gen) sekrit_gen "$@" ;;
|
||||||
get) sekrit_get "$@" ;;
|
get) sekrit_get "$@" ;;
|
||||||
has) sekrit_has "$@" ;;
|
has) sekrit_has "$@" ;;
|
||||||
|
Loading…
Reference in New Issue
Block a user