From fc2f7db3b2f5b6f0258e94143ba88378dd58f5c5 Mon Sep 17 00:00:00 2001 From: kar Date: Wed, 1 Jan 2025 14:17:48 -0500 Subject: rename angou to kasi Having a Japanese word as a project name sounds very childish when not I am not Japanese myself. Using a conlang is childish too when I don't know any words in it? I refuse to believe that. --- README | 24 ++++++------ angou | 96 ------------------------------------------------ angou.1 | 35 ------------------ contrib/angoumenu | 14 ------- contrib/autocomplete.ksh | 6 +-- contrib/autocomplete.zsh | 6 +-- contrib/kasimenu | 14 +++++++ kasi | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ kasi.1 | 35 ++++++++++++++++++ 9 files changed, 163 insertions(+), 163 deletions(-) delete mode 100755 angou delete mode 100644 angou.1 delete mode 100755 contrib/angoumenu create mode 100755 contrib/kasimenu create mode 100755 kasi create mode 100644 kasi.1 diff --git a/README b/README index d6d1d42..0ab4de6 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -angou (暗号) -============ +kasi ("veil"/"conceal" in Esperanto) +==================================== A simple password manager written in POSIX shell. Dependencies @@ -9,13 +9,13 @@ Dependencies - tree (for listing all your passwords and their directories) - a simple version is available in https://github.com/pyr/tree and in OpenBSD's ports - - can possibly be replaced with ls if you add ANGOU_LIST in your ~/.profile + - can possibly be replaced with ls if you add KASI_LIST in your ~/.profile - xsel (for copying password to clipboard, but can be changed to a different - command with the ANGOU_CLIPBOARD command that accepts stdin) + command with the KASI_CLIPBOARD command that accepts stdin) - a password generator - script uses contrib/random from this repo by default and expects it in your path - - can change by setting ANGOU_GEN_USER and ANGOU_GEN_PASS in your ~/.profile + - can change by setting KASI_GEN_USER and KASI_GEN_PASS in your ~/.profile Configuration ------------- @@ -23,17 +23,17 @@ In your ~/.profile or wherever you set environment variables, add something like this if you use age: export AGE_KEY=/nas/ssh/id_ed25519 export AGE_PUB=${AGE_KEY}.pub -export ANGOU_DIR=/nas/angou-age -export ANGOU_ENCRYPT="age -R $AGE_PUB" -export ANGOU_DECRYPT="age -d -i $AGE_KEY -o -" +export KASI_DIR=/nas/kasi-age +export KASI_ENCRYPT="age -R $AGE_PUB" +export KASI_DECRYPT="age -d -i $AGE_KEY -o -" If you use GnuPG, then add: export GPG_ID="user@email.tld" # or your key id -export ANGOU_DECRYPT="gpg -qd" -export ANGOU_ENCRYPT="gpg -er $GPG_ID -o -" +export KASI_DECRYPT="gpg -qd" +export KASI_ENCRYPT="gpg -er $GPG_ID -o -" For some other file encryptor, you'd need to be able to output the encrypted -file to stdout or change the last line of edit() that runs $ANGOU_ENCRYPT. +file to stdout or change the last line of edit() that runs $KASI_ENCRYPT. Why should I use this over password-store? ------------------------------------------ @@ -41,7 +41,7 @@ Don't. For a serious answer, it's because this doesn't depend on bash. Migrating from password-store ----------------------------- -Set the ANGOU_DIR environment variable to your password store directory. +Set the KASI_DIR environment variable to your password store directory. Auto-complete ------------- diff --git a/angou b/angou deleted file mode 100755 index 179775d..0000000 --- a/angou +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh -e - -# sets the directory with all your passwords -ANGOU_DIR=${ANGOU_DIR:-"$HOME/.angou/"} -# sets the command to copy into your clipboard (must accept stdin) -ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -i"} -# sets command to use when listing directory structure -ANGOU_LIST=${ANGOU_LIST:-"tree"} -# custom command for generating passwords/users -ANGOU_GEN_PASS=${ANGOU_GEN_PASS:-"random pass"} -ANGOU_GEN_USER=${ANGOU_GEN_USER:-"random user"} - -mkdir -p "$ANGOU_DIR" -cd "$ANGOU_DIR" - -# decrypt and print a password from ANGOU_DIR or print the directory structure -view() { - if [ -f "$1" ]; then - $ANGOU_DECRYPT "$1" - elif [ -d "${1:-.}" ]; then - tree "${1:-.}" - else - usage - exit 1 - fi -} - -# view the first line -view_single() { - [ ! -f "$1" ] && usage && exit 1 - - view "$1" | sed 1q | tr -d \\n -} - -# copy the first line from view to clipboard -copy() { - [ ! -f "$1" ] && usage && exit 1 - - view_single "$1" | $ANGOU_CLIPBOARD -} - -# create new or existing password in ANGOU_DIR -edit() { - [ -d "$1" ] && usage && exit 1 - - tmpfile="$(mktemp)" - - if [ "$2" = "generate" ]; then - $ANGOU_GEN_PASS >"$tmpfile" - echo "Username: $($ANGOU_GEN_USER)" >>"$tmpfile" - fi - - # edit a copy of a password if it already exists - [ -f "$1" ] && $ANGOU_DECRYPT "$1" > "$tmpfile" - - ${VISUAL:-${EDITOR:-ed}} "$tmpfile" - - mkdir -p "$(dirname "$1")" - $ANGOU_ENCRYPT "$tmpfile" >"$1" -} - -totp_view() { - [ -d "$1" ] && usage && exit 1 - - secret=$(view "$1" | grep TOTP | cut -d' ' -f 2) - oathtool -b --totp "$secret" -} - -totp() { - totp_view "$1" | tr -d '\n' | $ANGOU_CLIPBOARD -} - -# print usage -usage() { - printf "Usage: %s [help|copy|edit|generate|view|view_single [file or directory]]\n" "$0" - printf "\tThe edit and copy command expects a file as an argument,\n" - printf "\twhile the view command expects a directory as an argument.\n" - printf "\tThe arguments for view and edit are relative to\n" - printf "\t\$ANGOU_DIR which is currently set to %s\n\n" "$ANGOU_DIR" - - printf "\tThe view command is the default command if only a file or\n" - printf "\tdirectory is passed as an argument\n" -} - -option="$1" -case "$option" in - help) usage ;; - copy) copy "$2" ;; - edit) edit "$2" ;; - generate) edit "$2" generate ;; - view) view "$2" ;; - pass) view_single "$2" ;; - totp_view) totp_view "$2" ;; - totp) totp "$2" ;; - *) view "$1" ;; -esac diff --git a/angou.1 b/angou.1 deleted file mode 100644 index 015c2f5..0000000 --- a/angou.1 +++ /dev/null @@ -1,35 +0,0 @@ -.Dd 2021-10-11 -.Dt angou 1 -.Os -.Sh Name -.Nm angou -.Nd A pure posix shell implementation of the standard unix password manager, pass(1) -.Sh Synopsis -.Nm angou -.Op copy | edit | remove | view -.Op file or directory -.Sh Description -This exists because -.Xr pass 1 -is written in bash when it can be done in a more portable way without that. -.Pp -However, this is perfectly compatible with said tool. -.Sh Usage -.Nm angou -.Op copy -.Op file -.Pp -.Nm angou -.Op edit -.Op file -.Pp -.Nm angou -.Op remove -.Op file -.Pp -.Nm angou -.Op view -.Op file or directory -.Sh Authors -.An shokara -.Mt shokara@kalli.st diff --git a/contrib/angoumenu b/contrib/angoumenu deleted file mode 100755 index 85ca2e4..0000000 --- a/contrib/angoumenu +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -ANGOU_DIR="${ANGOU_DIR:-~/.angou}" -DMENU="dmenu" - -cd "$ANGOU_DIR" -file=$(find . -type f -printf '%P\n' | sort | sed 's,^\./,,' | $DMENU) - -if [ -z "$1" ]; then - angou copy "$file" -elif [ "$1" = "totp" ] - angou totp "$file" -else - exit 1 -fi diff --git a/contrib/autocomplete.ksh b/contrib/autocomplete.ksh index 5c91ad8..54d774a 100644 --- a/contrib/autocomplete.ksh +++ b/contrib/autocomplete.ksh @@ -1,4 +1,4 @@ #!/bin/ksh -set -A complete_angou_1 -- help copy edit view pass generate -set -A complete_angou_2 -- $(find ${ANGOU_DIR:-~/.angou} -type f | sort \ - | sed s,${ANGOU_DIR}/,, | sed s,\\.gpg$,,) +set -A complete_kasi_1 -- help copy edit view pass generate +set -A complete_kasi_2 -- $(find ${KASI_DIR:-~/.kasi} -type f | sort \ + | sed s,${KASI_DIR}/,, | sed s,\\.gpg$,,) diff --git a/contrib/autocomplete.zsh b/contrib/autocomplete.zsh index eaafb8c..1a8ea10 100644 --- a/contrib/autocomplete.zsh +++ b/contrib/autocomplete.zsh @@ -1,10 +1,10 @@ -#compdef angou +#compdef kasi passwords() { - files=("${(f)$(find ${ANGOU_DIR:-$HOME/.angou} -type f -printf '%P\n' | sort)}") + files=("${(f)$(find ${KASI_DIR:-$HOME/.kasi} -type f -printf '%P\n' | sort)}") _multi_parts / files } _arguments \ - '1:angou commands:(copy edit generate help pass view totp totp_view)' \ + '1:kasi commands:(copy edit generate help pass view totp totp_view)' \ '2:passwords:passwords' diff --git a/contrib/kasimenu b/contrib/kasimenu new file mode 100755 index 0000000..3a42745 --- /dev/null +++ b/contrib/kasimenu @@ -0,0 +1,14 @@ +#!/bin/sh +KASI_DIR="${KASI_DIR:-~/.kasi}" +DMENU="dmenu" + +cd "$KASI_DIR" +file=$(find . -type f -printf '%P\n' | sort | sed 's,^\./,,' | $DMENU) + +if [ -z "$1" ]; then + kasi copy "$file" +elif [ "$1" = "totp" ] + kasi totp "$file" +else + exit 1 +fi diff --git a/kasi b/kasi new file mode 100755 index 0000000..46a5584 --- /dev/null +++ b/kasi @@ -0,0 +1,96 @@ +#!/bin/sh -e + +# sets the directory with all your passwords +KASI_DIR=${KASI_DIR:-"$HOME/.kasi/"} +# sets the command to copy into your clipboard (must accept stdin) +KASI_CLIPBOARD=${KASI_CLIPBOARD:-"xsel -i"} +# sets command to use when listing directory structure +KASI_LIST=${KASI_LIST:-"tree"} +# custom command for generating passwords/users +KASI_GEN_PASS=${KASI_GEN_PASS:-"random pass"} +KASI_GEN_USER=${KASI_GEN_USER:-"random user"} + +mkdir -p "$KASI_DIR" +cd "$KASI_DIR" + +# decrypt and print a password from KASI_DIR or print the directory structure +view() { + if [ -f "$1" ]; then + $KASI_DECRYPT "$1" + elif [ -d "${1:-.}" ]; then + tree "${1:-.}" + else + usage + exit 1 + fi +} + +# view the first line +view_single() { + [ ! -f "$1" ] && usage && exit 1 + + view "$1" | sed 1q | tr -d \\n +} + +# copy the first line from view to clipboard +copy() { + [ ! -f "$1" ] && usage && exit 1 + + view_single "$1" | $KASI_CLIPBOARD +} + +# create new or existing password in KASI_DIR +edit() { + [ -d "$1" ] && usage && exit 1 + + tmpfile="$(mktemp)" + + if [ "$2" = "generate" ]; then + $KASI_GEN_PASS >"$tmpfile" + echo "Username: $($KASI_GEN_USER)" >>"$tmpfile" + fi + + # edit a copy of a password if it already exists + [ -f "$1" ] && $KASI_DECRYPT "$1" > "$tmpfile" + + ${VISUAL:-${EDITOR:-ed}} "$tmpfile" + + mkdir -p "$(dirname "$1")" + $KASI_ENCRYPT "$tmpfile" >"$1" +} + +totp_view() { + [ -d "$1" ] && usage && exit 1 + + secret=$(view "$1" | grep TOTP | cut -d' ' -f 2) + oathtool -b --totp "$secret" +} + +totp() { + totp_view "$1" | tr -d '\n' | $KASI_CLIPBOARD +} + +# print usage +usage() { + printf "Usage: %s [help|copy|edit|generate|view|view_single [file or directory]]\n" "$0" + printf "\tThe edit and copy command expects a file as an argument,\n" + printf "\twhile the view command expects a directory as an argument.\n" + printf "\tThe arguments for view and edit are relative to\n" + printf "\t\$KASI_DIR which is currently set to %s\n\n" "$KASI_DIR" + + printf "\tThe view command is the default command if only a file or\n" + printf "\tdirectory is passed as an argument\n" +} + +option="$1" +case "$option" in + help) usage ;; + copy) copy "$2" ;; + edit) edit "$2" ;; + generate) edit "$2" generate ;; + view) view "$2" ;; + pass) view_single "$2" ;; + totp_view) totp_view "$2" ;; + totp) totp "$2" ;; + *) view "$1" ;; +esac diff --git a/kasi.1 b/kasi.1 new file mode 100644 index 0000000..015c2f5 --- /dev/null +++ b/kasi.1 @@ -0,0 +1,35 @@ +.Dd 2021-10-11 +.Dt angou 1 +.Os +.Sh Name +.Nm angou +.Nd A pure posix shell implementation of the standard unix password manager, pass(1) +.Sh Synopsis +.Nm angou +.Op copy | edit | remove | view +.Op file or directory +.Sh Description +This exists because +.Xr pass 1 +is written in bash when it can be done in a more portable way without that. +.Pp +However, this is perfectly compatible with said tool. +.Sh Usage +.Nm angou +.Op copy +.Op file +.Pp +.Nm angou +.Op edit +.Op file +.Pp +.Nm angou +.Op remove +.Op file +.Pp +.Nm angou +.Op view +.Op file or directory +.Sh Authors +.An shokara +.Mt shokara@kalli.st -- cgit v1.2.3