Fix bugs, update docs

Signed-off-by: Aoi K <koizumi.aoi@kyoko-project.wer.ee>

git-svn-id: file:///srv/svn/repo/kanako/trunk@4 62e5d677-aa6e-8c4a-b8cb-b9416171cb8e
This commit is contained in:
koizumi.aoi 2022-10-11 18:53:26 +00:00
parent a8ab186175
commit 9ad0255afb
3 changed files with 24 additions and 17 deletions

29
kanako
View File

@ -22,23 +22,19 @@ else
fi fi
fn_copy() { fn_copy() {
fn_view $2 | ${clip} fn_view $1 | ${clip_cmd}
} }
fn_edit() { fn_edit() {
${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc ${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc > ${1%%.enc}
${EDITOR} ${1%%.enc} ${EDITOR} ${1%%.enc}
${encrypt_cmd} ${encrypt_args} ${1%%.enc} ${encrypt_cmd} ${encrypt_args} ${1%%.enc} > ${1%%.enc}.enc
rm ${1%%.enc} rm ${1%%.enc}
} }
fn_generate() { fn_generate() {
pwgen -s ${1:-80} pwgen -s ${1:-80}
} }
fn_list() { fn_list() {
if command -v tree 2>/dev/null; then ${list_cmd} ${store_dir}
tree ${store_dir}
else
ls -l ${store_dir}
fi
} }
fn_new() { fn_new() {
test -d $1 && fn_usage && exit 1 test -d $1 && fn_usage && exit 1
@ -47,9 +43,7 @@ fn_new() {
${EDITOR} ${tmpfile} ${EDITOR} ${tmpfile}
mkdir -p $(dirname $1) mkdir -p $(dirname $1)
${encrypt_cmd} ${encrypt_args} ${tmpfile} ${encrypt_cmd} ${encrypt_args} ${tmpfile} > ${1%%.enc}.enc
mv ${tmpfile}.enc ${1%%.enc}.enc
rm ${tmpfile} rm ${tmpfile}
} }
fn_trash_directory() { fn_trash_directory() {
@ -61,10 +55,19 @@ fn_trash_entry() {
fn_usage() { fn_usage() {
cat <<EOF cat <<EOF
Usage: Usage:
ayu [-ceglnrRv] <arguments> kanako [-ceglnrRv] <arguments>
ayu [copy|edit|gen|list|add|trash|trashd|view] <arguments> kanako [copy|edit|gen|list|add|trash|trashd|view] <arguments>
EOF EOF
} }
fn_view() {
if [ -f ${1%%.enc}.enc ]; then
${encrypt_cmd} ${decrypt_args} ${1%%.enc}.enc
elif [ -d ${1:-.} ]; then
${list_cmd} ${1:-.}
else
fn_usage
fi
}
case $1 in case $1 in
-c | copy) fn_copy $2 ;; -c | copy) fn_copy $2 ;;

View File

@ -1,5 +1,7 @@
# [General] # [General]
#clip="xclip -i" #clip="xclip -i"
#clip="wl-copy --primary"
#list_cmd="tree"
# [Encryption] # [Encryption]
## age ## age

View File

@ -8,15 +8,17 @@
.Sh KEYS .Sh KEYS
.Ss General section .Ss General section
.Bl -tag -width 11n -compact .Bl -tag -width 11n -compact
.It clip .It clip_cmd
Clipboard program to use with Clipboard executable to use with
the program. Default is xclip the program.
.It list_cmd
Listing executable to use
with the program.
.El .El
.Ss Encryption section .Ss Encryption section
.Bl -tag -width 11n -compact .Bl -tag -width 11n -compact
.It encrypt_cmd .It encrypt_cmd
Command to handle encryption Command to handle encryption
Default is 'age'
.It encrypt_args .It encrypt_args
Options to be passed to Options to be passed to
encrypt_cmd for encryption encrypt_cmd for encryption