diff --git a/shell/traverse_rnote.sh b/shell/traverse_rnote.sh index f381c6b..a85c2b1 100755 --- a/shell/traverse_rnote.sh +++ b/shell/traverse_rnote.sh @@ -1,16 +1,17 @@ #!/usr/bin/env bash -# Directory to search (default: current directory or given argument) -SEARCH_DIR="${1:-.}" +# Directories to search (default: current directory if none provided) +SEARCH_DIRS=("${@:-.}") -# Your Rnote file viewer (default command to open .rnote files) +# Your Rnote file viewer RNOTE_VIEWER="rnote" # Ensure fzf and the viewer exist command -v fzf >/dev/null 2>&1 || { echo "fzf not found"; exit 1; } command -v "$RNOTE_VIEWER" >/dev/null 2>&1 || { echo "$RNOTE_VIEWER not found"; exit 1; } -# Find all .rnote files recursively and open them interactively with fzf -find "$SEARCH_DIR" -type f -iname '*.rnote' | sort | \ -fzf --multi \ - --bind "enter:execute-silent($RNOTE_VIEWER {} &)" \ +# Find all .rnote files recursively, sorted by modification time (newest first) +find "${SEARCH_DIRS[@]}" -type f -iname '*.rnote' -printf '%T@ %p\n' | \ + sort -nr | cut -d' ' -f2- | \ + fzf --multi \ + --bind "enter:execute-silent($RNOTE_VIEWER {} &)" diff --git a/shell/uni_setup.sh b/shell/uni_setup.sh new file mode 100755 index 0000000..e83ac13 --- /dev/null +++ b/shell/uni_setup.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Select a parent folder using fzf +parent_folder=$(find ~/Nextcloud/University -mindepth 1 -type d | fzf --prompt="Select parent folder: ") || exit + +# Find latest modified PDF and .rnote in that folder (non-recursive) +latest_pdf=$(find "$parent_folder" -maxdepth 1 -type f -name "*.pdf" -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2-) +latest_rnote=$(find "$parent_folder" -maxdepth 1 -type f -name "*.rnote" -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2-) + +# Open them with default apps +[[ -n "$latest_pdf" ]] && xdg-open "$latest_pdf" > /dev/zero 2>&1 & +[[ -n "$latest_rnote" ]] && xdg-open "$latest_rnote" > /dev/zero 2>&1 &