From 2fda4cbad215bedb2fe26c7f0117d500562f9c04 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Thu, 31 Jan 2013 13:33:33 -0800 Subject: [PATCH] Fix check_empty and add show command to note check_empty for restore was trying to run a git checkout in the current working directory, instead of in the ~/.notes directory. Fix this issue note_show uses less to display the contents of the note file. --- note | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/note b/note index b3132b8..a5e4952 100755 --- a/note +++ b/note @@ -68,11 +68,14 @@ check_empty() { then if [[ "$1" == "restore" ]] then + cd "$NOTES_DIR" gitfile=$(basename "$note_file") git checkout $gitfile + echo "Restored empty note $note_arg" elif [[ "$1" == "delete" ]] then rm -f $note_file + echo "Deleted empty note $note_arg" fi exit @@ -198,6 +201,19 @@ note_edit() { echo "Updated note '$note_new_title'" } +note_show() { + check_dir + check_arg + title_to_name + if ! note_exists + then + echo "Cannot find note '$note_arg'!" + exit + fi + + less -R $note_file +} + note_delete() { check_dir check_arg @@ -266,6 +282,10 @@ parse_args() { note_edit ;; + "show") + note_show + ;; + "del" | "delete") note_delete ;;