commit fd8e44b27fbcfe2e753dde4c093bb95680b3d056
Author: Shokara <shokara@snopyta.org>
Date: Sat, 12 Jun 2021 00:13:41 -0400
initial payload
Diffstat:
| A | LICENSE | | | 13 | +++++++++++++ |
| A | README | | | 21 | +++++++++++++++++++++ |
| A | angou | | | 59 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2021 Shokara Kou
+
+Permission to use, copy, modify, and distribute this software for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/README b/README
@@ -0,0 +1,21 @@
+angou (暗号)
+============
+A simple password manager written in POSIX shell.
+
+Dependencies
+------------
+- POSIX-compliant environment
+- gnupg
+- 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
+- xsel (for copying password to clipboard, but can be changed to a different
+ command with the ANGOU_CLIPBOARD command that accepts stdin)
+
+Why should I use this over password-store?
+------------------------------------------
+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.
diff --git a/angou b/angou
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# 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 -ib"}
+
+mkdir -p "$ANGOU_DIR"
+cd "$ANGOU_DIR" || exit
+
+# print the directory structure of ANGOU_DIR
+list() {
+ tree "$@"
+}
+
+# decrypt and print a password from ANGOU_DIR
+view() {
+ gpg -qd "${1%%.gpg}".gpg
+}
+
+# copy the first line from view to clipboard
+copy() {
+ view "$1" | "$ANGOU_CLIPBOARD"
+}
+
+# create new or existing password in ANGOU_DIR
+edit() {
+ tmpfile="$(mktemp)"
+
+ # edit a copy of a password if it already exists
+ test [ -f "${1**.gpg}".gpg] && cp "$1" "$tmpfile"
+
+ "${VISUAL:-${EDITOR:-ed}}" "$tmpfile"
+
+ mkdir -p "$(dirname "$1")"
+ mv "$tmpfile" "${1%%.gpg}".gpg
+}
+
+# print usage
+usage() {
+ printf "Usage: %s [help|view|copy|edit|list [file or directory]]\n" "$1"
+ printf "\tThe view and edit commands expect a file as an argument,\n"
+ printf "\twhile the list commands expect a directory as an argument.\n"
+ printf "\tThe arguments for view, edit, and list are relative to\n"
+ printf "\t\$ANGOU_DIR which is currently set to %s\n\n" "$ANGOU_DIR"
+
+ printf "\tThe list command is the default option if only a file or\n"
+ printf "\tdirectory is passed as an argument\n"
+}
+
+option="$1"
+case "$option" in
+ help) usage "$0" ;;
+ view) view "$2" ;;
+ copy) copy "$2" ;;
+ edit) edit "$2" ;;
+ list) shift && list "$@" ;; # fallthrough isn't in posix sh?
+ *) list "$@" ;;
+esac