diff options
author | Matthew Lemon <y@yulqen.org> | 2024-09-05 08:43:25 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-09-05 08:43:31 +0100 |
commit | ca6b824a82bc8f277c370b4ae24ba40d248988ce (patch) | |
tree | 2cb64bffee8345c884cac13388d2b5b1f2df41d8 /note_importer.sh | |
parent | 1ecb2e8e4023f366b90fc62a1ab746d147a04b66 (diff) |
Adds documents backup and note_importer scripts
Diffstat (limited to 'note_importer.sh')
-rwxr-xr-x | note_importer.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/note_importer.sh b/note_importer.sh new file mode 100755 index 0000000..fda041a --- /dev/null +++ b/note_importer.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check if file was provided as argument +if [ -z "$1" ]; then + echo "Error: No file specified." + exit +fi + +# Display file in pager (less) +less "$1" + +# Ask user if they want to import the file +echo "Import this file? (y/n)" +read -r IMPORT_RESPONSE + +if [ "${IMPORT_RESPONSE,,}" = "n" ]; then + # Ask user if they want to delete the file + echo "Delete this file instead? (y/n)" + read -r DELETE_RESPONSE + + case ${DELETE_RESPONSE,,} in + y) rm "$1"; exit ;; + n) exit ;; + esac + +else + # Append contents of file to scratchpad.txt + NOTE=$(basename -s .md -- "$1") + cat >> ~/Documents/Notes/Scratch/scratchpad.txt <<EOF +NOTE: $NOTE {{{ +$(cat "$1") }}} +EOF + rm "$1"; exit + exit +fi |