micro change )

This commit is contained in:
Maksim Totmin 2024-05-20 15:58:09 +07:00
parent c577c7c76e
commit 145846d37a
3 changed files with 29 additions and 15 deletions

View File

@ -2,7 +2,7 @@
Simple pass like notes manager on bash.
To-Do:
* [ ] Update help
* [ ] rm/del notes feature
* [x] Update help
* [x] rm/del notes feature
* [x] Autocomplite feature
* [ ] Sync with git

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
PN="$HOME/.note-store/"
touch $PN/readme.md
echo "# NotesMenu" > $PN/readme.md

36
note
View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
VER=0.0.1
NOTESPATH="$HOME/.note-store"
@ -18,10 +18,12 @@ CMD_HELP(){
Usage:
$PROGRAM init
Initialize new note storage.
$PROGRAM [ls]
$PROGRAM [ls] [subfolder]
List notes.
$PROGRAM [edit] note-name
$PROGRAM edit note-name
Insert a new note or edit an existing note using editor.
$PROGRAM rm [--recursive,-r] [--force,-f] note-name
Remove existing note or directory, optionally forcefully.
$PROGRAM help
Show this text.
$PROGRAM version
@ -32,19 +34,31 @@ _EOF
}
CMD_INIT(){
test -d "$NOTESPATH" && echo "Note Store already exist" && exit 0 ||
mkdir "$NOTESPATH" &> /dev/null
local path="${1%/}"
local notefile="$NOTESPATH/$path.md"
check_sneaky_paths "$path"
[[ $force -eq 0 && -e $passfile ]] && yesno "An entry already exists for $path. Overwrite it?"
mkdir -p -v "$NOTESPATH/$(dirname -- "$path")"
echo "New note storage creted to: "$NOTESPATH""
exit 0
}
CMD_SHOWTREE(){
if [ ! -z "$1" ]; then
glow -p $NOTESPATH/"$1.md"
else
echo "Note Store"
tree -N -C -l --noreport "$NOTESPATH" | tail -n +2 |\
local path="$1"
local notefile="$NOTESPATH/$path.md"
if [ -d $NOTESPATH/$path ]; then
if [[ -z $path ]]; then
echo "Note Store"
else
echo "${path%\/}"
fi
tree -N -C -l --noreport "$NOTESPATH/$path" | tail -n +2 |\
sed -E 's/\.md(\x1B\[[0-9]+m)?( ->|$)/\1\2/g'
else
glow -p $NOTESPATH/$path.md
fi
exit 0
}
@ -63,6 +77,7 @@ CMD_GREP(){
CMD_DELETE(){
local opts recursive="" force=0
te
opts="$($GETOPT -o rf -l recursive,force -n "$PROGRAM" -- "$@")"
local err=$?
eval set -- "$opts"
@ -134,7 +149,6 @@ PROGRAM="${0##*/}"
COMMAND="$1"
GETOPT="getopt"
SHRED="shred -f -z"
BASE64="base64"
case "$1" in
init) shift; CMD_INIT "$@" ;;