about summary refs log tree commit diff stats
path: root/ayu
diff options
context:
space:
mode:
authorAoi Koizumi <novaburst@kalli.st>2022-01-28 20:34:31 -0300
committerAoi Koizumi <novaburst@kalli.st>2022-01-28 20:34:31 -0300
commit46b1c4e1be64d3fa4be3597d87d469b8423b043e (patch)
treeba8ae0e5d89ef01d806d55a825398ec75502e134 /ayu
parentc9e2e86b097d9e5b86f00aeeeedb18fce68e5ead (diff)
downloadayu-46b1c4e1be64d3fa4be3597d87d469b8423b043e.tar.gz
Check the commit log for changes, there are a lot!
Signed-off-by: Aoi Koizumi <novaburst@kalli.st>
Diffstat (limited to 'ayu')
-rwxr-xr-xayu77
1 files changed, 35 insertions, 42 deletions
diff --git a/ayu b/ayu
index 23ab4ec..b6b22c6 100755
--- a/ayu
+++ b/ayu
@@ -3,32 +3,41 @@
 # ayu(1) - an actually boring password manager, which uses age(1) as backend.
 
 # Path to the program's directory
-ayu_dir="${ayu_dir:-$HOME/.config/ayu}"
+ayu_dir="${ayu_dir:-$HOME/.ayu}"
 
 # Path to the password store
-ayu_store="${ayu_store:-$HOME/.ayu}"
+ayu_store="${ayu_store:-$HOME/.ayu-store}"
+
+# Command to copy an entry's text into the clipboard (must accept standard input)
+clipboard="xsel -ib"
 
 # Path to the age(1) keys
-ayu_key="${ayu_key:-${ayu_dir}/sec.age}"
-ayu_pub="${ayu_pub:-${ayu_dir}/pub.age}"
+private_key="${private_key:-${ayu_dir}/private_key}"
+public_key="${public_key:-${ayu_dir}/public_key}"
 
+# Default editor to be used
 EDITOR=${EDITOR:-vi}
 
 # Run some tests
 test -d $ayu_dir || mkdir -p $ayu_dir
 test -d $ayu_store || mkdir -p $ayu_store
 
-test -f $ayu_key || printf "$0: Generate your own age(1) key with age-keygen(1) and place it as a $ayu_key. \n"
-test -f $ayu_pub || printf "$0: Public key needs to be placed on $ayu_pub (Hint: it's the visible output of age-keygen(1)) \n"
+test -f $private_key || printf "$0: Generate your own age(1) key with age-keygen(1) and place it as a $private_key. \n"
+test -f $public_key || printf "$0: Public key needs to be placed on $public_key (Hint: it's the visible output of age-keygen(1)) \n"
 
 # Switch directory to the password store, otherwise bail out.
 cd $ayu_store || exit 1
 
+# Copy an entry to the clipboard
+copy() {
+	view "$2" | sed 1q | $clipboard
+}
+
 # Edit an entry if it exists
 edit() {
-	age --decrypt --identity=$ayu_key --output=${1%%.age} ${1%%.age}.age
+	age --decrypt --identity=$private_key --output=${1%%.age} ${1%%.age}.age
 	${EDITOR} ${1%%.age}
-	age --encrypt -R $ayu_pub --output=${1%%.age}.age ${1%%.age}
+	age --encrypt -R $public_key --output=${1%%.age}.age ${1%%.age}
 	rm ${1%%.age}
 }
 
@@ -45,31 +54,30 @@ new() {
 	${EDITOR} "$tmpfile"
 
 	mkdir -p "$(dirname "$1")"
-	age --encrypt -R $ayu_pub -o $tmpfile.age $tmpfile
+	age --encrypt -R $public_key -o $tmpfile.age $tmpfile
 
 	mv $tmpfile.age "${1%%.age}".age
 	rm $tmpfile
 }
 
 # Remove
-re() {
-	rm -v ${1}${2}.age
-}
-# Remove-recursive
-rr() {
-	test -d "$@" && usage && exit
-	rm -r -v "$(dirname "$@")"
+remove() {
+	rm -f ${1}${2}.age
 }
 
+# Remove recursively
+remove_recursive() {
+	rm -rf "$@"
+}
 # Print usage
 usage() {
-	printf "$0 [ ed | ls | new | re | rr | vi ] \n"
+	printf "$0 [ -c | -e | -l | -n | -r | -R | -v ] <entry> \n"
 }
 
 # View an entry, otherwise list the contents of the directory specified.
 view() {
 	if [ -f "${1%%.age}".age ];then
-		age --decrypt --identity=$ayu_key "${1%%.age}".age
+		age --decrypt --identity=$private_key "${1%%.age}".age
 	elif [ -d "${1:-.}" ];then
 		tree "${1:-.}"
 	else
@@ -79,28 +87,13 @@ view() {
 }
 
 case $1 in
-	edit | ed)
-		edit $2
-		;;
-	list | ls)
-		list
-		;;
-	new)
-		new $2
-		;;
-	remove | re)
-		re $2 $3
-		;;
-	remove-recursive | rr)
-		rr $2
-		;;
-	usage)
-		usage
-		;;
-	view | vi)
-		view $2
-		;;
-	*)
-		list
-		;;
+	-c) copy $2 ;;
+	-e) edit $2 ;;
+	-l) list ;;
+	-n) new $2 ;;
+	-r) remove $2 $3 ;;
+	-R) remove_recursive $2 ;;
+	-h) usage ;;
+	-v) view $2 ;;
+	*) usage ;;
 esac
2' href='/akkartik/mu/commit/cpp/021call?h=hlt&id=ca01193d8b4c564766727bf13b4a4c51db14715a'>ca01193d ^
e2240eb4 ^
69e14325 ^
5eb49929 ^
e2240eb4 ^

0b0cfb6f ^
31401373 ^
d72f3799 ^
0b0cfb6f ^
7284d503 ^


a66c9ae6 ^

31401373 ^

ec926027 ^
7c8493b3 ^

31401373 ^

ec926027 ^
dcfca05e ^

31401373 ^

dcfca05e ^
f89378d5 ^
f1a6f323 ^
9cf71627 ^
2199940a ^
dcfca05e ^
768bdb4d ^
9cf71627 ^

31401373 ^
a767dbd3 ^
9cf71627 ^

7284d503 ^
64cf0a59 ^
69e14325 ^


df8bb4c3 ^
f6d47435 ^
5eb49929 ^
31401373 ^

5eb49929 ^

f1e953d0 ^
ec926027 ^

5eb49929 ^
31401373 ^
b75e94b3 ^
ec926027 ^
8eff7919 ^
f6d47435 ^
f278a15d ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109