mirror of https://github.com/nirenjan/dotfiles.git
Fix note script for title renaming
Also add a debug print statement for when NOTES_DEBUG is set.master
parent
17e9f45505
commit
0ecbe0605d
13
note
13
note
|
@ -7,6 +7,12 @@ NOTES_DIR="$HOME/.notes"
|
||||||
# Initialize with the default editor
|
# Initialize with the default editor
|
||||||
[ -z "$EDITOR" ] && EDITOR="/usr/bin/vim"
|
[ -z "$EDITOR" ] && EDITOR="/usr/bin/vim"
|
||||||
|
|
||||||
|
dprint() {
|
||||||
|
if [ ! -z $NOTES_DEBUG ]; then
|
||||||
|
echo $*
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
notes_init() {
|
notes_init() {
|
||||||
# Check if the notes folder exists, if not, create it
|
# Check if the notes folder exists, if not, create it
|
||||||
if [ ! -d $NOTES_DIR ]
|
if [ ! -d $NOTES_DIR ]
|
||||||
|
@ -23,7 +29,7 @@ notes_init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
make_title() {
|
make_title() {
|
||||||
echo "$*" | sed 's/[^A-Za-z0-9_-]\+/-/g' | \
|
echo "$*" | sed 's/[^A-Za-z0-9_]\+/-/g' | \
|
||||||
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
|
sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,9 +130,12 @@ parse_args() {
|
||||||
|
|
||||||
note_new_title=$(head -1 $note_file)
|
note_new_title=$(head -1 $note_file)
|
||||||
note_new_md5=$(md5sum $note_file)
|
note_new_md5=$(md5sum $note_file)
|
||||||
note_new_file=$(make_title $note_new_title)
|
note_new_file=$NOTES_DIR/$(make_title $note_new_title)
|
||||||
check_md5 $note_file
|
check_md5 $note_file
|
||||||
|
|
||||||
|
dprint "Original filename = " $note_file
|
||||||
|
dprint "New filename = " $note_new_file
|
||||||
|
|
||||||
# Check for a title rename
|
# Check for a title rename
|
||||||
if [[ "$note_file" != "$note_new_file" ]]
|
if [[ "$note_file" != "$note_new_file" ]]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in New Issue