source: code/trunk/ayu-ng@ 1

Last change on this file since 1 was 1, checked in by koizumi.aoi, 3 years ago

Initial payload

Signed-off-by: Aoi K <koizumi.aoi@…>

  • Property svn:executable set to on
File size: 1.2 KB
Line 
1#!/bin/sh -e
2
3conf_dir=${conf_dir:-$HOME/.config/ayu}
4key_dir=${key_dir:-$HOME/.ayu}
5store_dir=${store_dir:-$HOME/.ayu-store}
6
7cd ${store_dir} || exit 1
8
9. ${conf_dir}/config
10
11fn_copy() {
12 fn_view $2 | ${clip}
13}
14fn_edit() {
15 ${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc
16 ${EDITOR} ${1%%.enc}
17 ${encrypt_cmd} ${encrypt_args} ${1%%.enc}
18 rm ${1%%.enc}
19}
20fn_generate() {
21 pwgen -s ${2:-80}
22}
23fn_list() {
24 if command -v tree 2>/dev/null; then
25 tree ${store_dir}
26 else
27 ls -l ${store_dir}
28 fi
29}
30fn_new() {
31 test -d $1 && fn_usage && exit 1
32
33 tmpfile=$(mktemp)
34 ${EDITOR} ${tmpfile}
35
36 mkdir -p $(dirname $1)
37 ${encrypt_cmd} ${encrypt_args} ${tmpfile}
38
39 mv ${tmpfile}.enc ${1%%.enc}.enc
40 rm ${tmpfile}
41}
42fn_trash_directory() {
43 rm -rf $@
44}
45fn_trash_entry() {
46 rm -f ${1}${2},enc
47}
48fn_usage() {
49 cat <<EOF
50Usage:
51ayu [-ceglnrRv] <arguments>
52ayu [copy|edit|generate|list|add|trash|trashdir|view] <arguments>
53EOF
54}
55
56case $1 in
57 -c | copy) fn_copy $2 ;;
58 -e | edit) fn_edit $2 ;;
59 -g | generate) fn_generate $2 ;;
60 -l | list) fn_list ;;
61 -n | add) fn_new ;;
62 -r | trash) fn_trash $2 ;;
63 -R | trashd) fn_trash_directory $2 ;;
64 -v | view) fn_view $2 ;;
65 *) fn_usage ;;
66esac
Note: See TracBrowser for help on using the repository browser.