diff --git a/kanako b/kanako index 934c45f..40023ae 100755 --- a/kanako +++ b/kanako @@ -22,23 +22,19 @@ else fi fn_copy() { - fn_view $2 | ${clip} + fn_view $1 | ${clip_cmd} } fn_edit() { - ${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc + ${decrypt_cmd} ${decrypt_args} ${1%%.enc}.enc > ${1%%.enc} ${EDITOR} ${1%%.enc} - ${encrypt_cmd} ${encrypt_args} ${1%%.enc} + ${encrypt_cmd} ${encrypt_args} ${1%%.enc} > ${1%%.enc}.enc rm ${1%%.enc} } fn_generate() { pwgen -s ${1:-80} } fn_list() { - if command -v tree 2>/dev/null; then - tree ${store_dir} - else - ls -l ${store_dir} - fi + ${list_cmd} ${store_dir} } fn_new() { test -d $1 && fn_usage && exit 1 @@ -47,9 +43,7 @@ fn_new() { ${EDITOR} ${tmpfile} mkdir -p $(dirname $1) - ${encrypt_cmd} ${encrypt_args} ${tmpfile} - - mv ${tmpfile}.enc ${1%%.enc}.enc + ${encrypt_cmd} ${encrypt_args} ${tmpfile} > ${1%%.enc}.enc rm ${tmpfile} } fn_trash_directory() { @@ -61,10 +55,19 @@ fn_trash_entry() { fn_usage() { cat < -ayu [copy|edit|gen|list|add|trash|trashd|view] +kanako [-ceglnrRv] +kanako [copy|edit|gen|list|add|trash|trashd|view] 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 -c | copy) fn_copy $2 ;; diff --git a/kanako.conf.example b/kanako.conf.example index 0a270a5..c053645 100644 --- a/kanako.conf.example +++ b/kanako.conf.example @@ -1,5 +1,7 @@ # [General] #clip="xclip -i" +#clip="wl-copy --primary" +#list_cmd="tree" # [Encryption] ## age diff --git a/kanako.conf.mdoc b/kanako.conf.mdoc index 80f5175..071b538 100644 --- a/kanako.conf.mdoc +++ b/kanako.conf.mdoc @@ -8,15 +8,17 @@ .Sh KEYS .Ss General section .Bl -tag -width 11n -compact -.It clip -Clipboard program to use with -the program. Default is xclip +.It clip_cmd +Clipboard executable to use with +the program. +.It list_cmd +Listing executable to use +with the program. .El .Ss Encryption section .Bl -tag -width 11n -compact .It encrypt_cmd Command to handle encryption -Default is 'age' .It encrypt_args Options to be passed to encrypt_cmd for encryption