summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE13
-rw-r--r--README21
-rwxr-xr-xangou59
3 files changed, 93 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..4376699
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
1Copyright 2021 Shokara Kou
2
3Permission to use, copy, modify, and distribute this software for any purpose
4with or without fee is hereby granted, provided that the above copyright notice
5and this permission notice appear in all copies.
6
7THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13PERFORMANCE OF THIS SOFTWARE.
diff --git a/README b/README
new file mode 100644
index 0000000..08ddebd
--- /dev/null
+++ b/README
@@ -0,0 +1,21 @@
1angou (暗号)
2============
3A simple password manager written in POSIX shell.
4
5Dependencies
6------------
7- POSIX-compliant environment
8- gnupg
9- tree (for listing all your passwords and their directories)
10 - a simple version is available in https://github.com/pyr/tree
11 and in OpenBSD's ports
12- xsel (for copying password to clipboard, but can be changed to a different
13 command with the ANGOU_CLIPBOARD command that accepts stdin)
14
15Why should I use this over password-store?
16------------------------------------------
17Don't. For a serious answer, it's because this doesn't depend on bash.
18
19Migrating from password-store
20-----------------------------
21Set the ANGOU_DIR environment variable to your password store directory.
diff --git a/angou b/angou
new file mode 100755
index 0000000..756df71
--- /dev/null
+++ b/angou
@@ -0,0 +1,59 @@
1#!/bin/sh
2
3# sets the directory with all your passwords
4ANGOU_DIR=${ANGOU_DIR:-"$HOME/.angou/"}
5# sets the command to copy into your clipboard (must accept stdin)
6ANGOU_CLIPBOARD=${ANGOU_CLIPBOARD:-"xsel -ib"}
7
8mkdir -p "$ANGOU_DIR"
9cd "$ANGOU_DIR" || exit
10
11# print the directory structure of ANGOU_DIR
12list() {
13 tree "$@"
14}
15
16# decrypt and print a password from ANGOU_DIR
17view() {
18 gpg -qd "${1%%.gpg}".gpg
19}
20
21# copy the first line from view to clipboard
22copy() {
23 view "$1" | "$ANGOU_CLIPBOARD"
24}
25
26# create new or existing password in ANGOU_DIR
27edit() {
28 tmpfile="$(mktemp)"
29
30 # edit a copy of a password if it already exists
31 test [ -f "${1**.gpg}".gpg] && cp "$1" "$tmpfile"
32
33 "${VISUAL:-${EDITOR:-ed}}" "$tmpfile"
34
35 mkdir -p "$(dirname "$1")"
36 mv "$tmpfile" "${1%%.gpg}".gpg
37}
38
39# print usage
40usage() {
41 printf "Usage: %s [help|view|copy|edit|list [file or directory]]\n" "$1"
42 printf "\tThe view and edit commands expect a file as an argument,\n"
43 printf "\twhile the list commands expect a directory as an argument.\n"
44 printf "\tThe arguments for view, edit, and list are relative to\n"
45 printf "\t\$ANGOU_DIR which is currently set to %s\n\n" "$ANGOU_DIR"
46
47 printf "\tThe list command is the default option if only a file or\n"
48 printf "\tdirectory is passed as an argument\n"
49}
50
51option="$1"
52case "$option" in
53 help) usage "$0" ;;
54 view) view "$2" ;;
55 copy) copy "$2" ;;
56 edit) edit "$2" ;;
57 list) shift && list "$@" ;; # fallthrough isn't in posix sh?
58 *) list "$@" ;;
59esac