aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-09-05 08:43:25 +0100
committerMatthew Lemon <y@yulqen.org>2024-09-05 08:43:31 +0100
commitca6b824a82bc8f277c370b4ae24ba40d248988ce (patch)
tree2cb64bffee8345c884cac13388d2b5b1f2df41d8
parent1ecb2e8e4023f366b90fc62a1ab746d147a04b66 (diff)
Adds documents backup and note_importer scripts
-rwxr-xr-xdocuments-backup.sh8
-rwxr-xr-xnote_importer.sh35
2 files changed, 43 insertions, 0 deletions
diff --git a/documents-backup.sh b/documents-backup.sh
new file mode 100755
index 0000000..f317d84
--- /dev/null
+++ b/documents-backup.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Define the source and destination directories
+SRC_DIR=/home/$USER/Documents
+DST_HOST=bach:/mnt/encrypted/matt_backups/
+
+# Run rsync command using ssh for encryption
+rsync -avz --delete "$SRC_DIR" "$DST_HOST"
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