Release 2.1
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: file:///srv/svn/repo/kanako/trunk@22 62e5d677-aa6e-8c4a-b8cb-b9416171cb8e
This commit is contained in:
parent
f73d683a30
commit
12ab49594b
@ -12,6 +12,7 @@ the adaptable password manager. named after [Kanako Yasaka](https://en.touhouwik
|
||||
* `tree(1)` for printing a list
|
||||
* `mandoc(1)` for documentation
|
||||
* `rm(1)` with the `-i` and `-I` switches
|
||||
* `strings(1)`, `dd(1)` and `tr(1)` for generating passwords
|
||||
|
||||
## Add-ons
|
||||
|
||||
|
26
kanako
26
kanako
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# $TheSupernovaDuo: kanako,v 2.0 2023/09/11 13:59:00 yakumo_izuru Exp $
|
||||
# $TheSupernovaDuo: kanako,v 2.1 2023/10/25 01:50:28 yakumo_izuru Exp $
|
||||
|
||||
readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}"
|
||||
readonly kanako_key_dir="${kanako_key_dir:-$HOME/.kanako}"
|
||||
@ -23,14 +23,18 @@ else
|
||||
fi
|
||||
|
||||
copy() {
|
||||
view $1 | "${kanako_clip_cmd}"
|
||||
view "$1" | "${kanako_clip_cmd}"
|
||||
}
|
||||
edit() {
|
||||
# FIXME: Need a way to find out if file exists
|
||||
${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc > ${1%%.enc}
|
||||
"${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}"
|
||||
${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} > ${1%%.enc}.enc
|
||||
rm "${1%%.enc}"
|
||||
}
|
||||
gen() {
|
||||
printf "%s\n" $(strings </dev/urandom | dd bs=1 count="${1:-30}" 2>/dev/null | tr -d ' \t\n\r')
|
||||
}
|
||||
list() {
|
||||
if [ -z "$1" ]; then
|
||||
$(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g'
|
||||
@ -39,7 +43,7 @@ list() {
|
||||
fi
|
||||
}
|
||||
new() {
|
||||
test -d $1 && usage && exit 1
|
||||
test -d "$1" && usage
|
||||
|
||||
tmpfile="$(mktemp)"
|
||||
"${EDITOR:-${EDITOR:-vi}}" "${tmpfile}"
|
||||
@ -48,16 +52,17 @@ new() {
|
||||
${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} > ${1%%.enc}.enc
|
||||
rm ${tmpfile}
|
||||
}
|
||||
trash_directory() {
|
||||
delete_directory() {
|
||||
rm -r -I "$1"
|
||||
}
|
||||
trash_file() {
|
||||
delete_file() {
|
||||
rm -i "${1}${2}".enc
|
||||
}
|
||||
usage() {
|
||||
printf "Usage: %s [-c|-e|-h|-l|-n|-R|-r|-v [file or directory]]\n" "$0"
|
||||
printf "The arguments for all switches except for '-h' are relative to\n"
|
||||
printf "\t\$kanako_store_dir which is set to %s\n\n" "{$kanako_store_dir}"
|
||||
printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0"
|
||||
printf "The arguments for all switches are relative to \${kanako_store_dir}\n"
|
||||
printf "which is located at %s\n" "${kanako_store_dir}"
|
||||
exit 1
|
||||
}
|
||||
view() {
|
||||
if [ -f "${1%%.enc}".enc ]; then
|
||||
@ -72,10 +77,11 @@ view() {
|
||||
case $1 in
|
||||
-c) copy $2 ;;
|
||||
-e) edit $2 ;;
|
||||
-g) gen $2 ;;
|
||||
-l) list $2;;
|
||||
-n) new $2 ;;
|
||||
-R) trash_directory $2 ;;
|
||||
-r) trash_file $2 ;;
|
||||
-R) delete_directory $2 ;;
|
||||
-r) delete_file $2 ;;
|
||||
-v) view $2 ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
|
@ -8,6 +8,7 @@
|
||||
.Nm
|
||||
.Fl c Ar args
|
||||
.Fl e Ar args
|
||||
.Fl g Ar args
|
||||
.Fl l
|
||||
.Fl n Ar args
|
||||
.Fl r Ar args
|
||||
@ -30,6 +31,8 @@ Add a new entry
|
||||
Copy an entry's text to the clipboard
|
||||
.It -e
|
||||
Edit an entry
|
||||
.It -g
|
||||
Generate a random password
|
||||
.It -l
|
||||
List all entries
|
||||
.It -r
|
||||
|
Loading…
x
Reference in New Issue
Block a user