From e30c304663232fde473029d1cbcae50440174696 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 4 Sep 2023 10:23:32 +0100 Subject: Fixes zetrename and adds mdlinkopen script --- mdlinkopen | 11 +++++++++++ zetrename | 36 ++++++++++++++++++++++++++++++++++++ zetrename.sh | 36 ------------------------------------ 3 files changed, 47 insertions(+), 36 deletions(-) create mode 100755 mdlinkopen create mode 100755 zetrename delete mode 100755 zetrename.sh diff --git a/mdlinkopen b/mdlinkopen new file mode 100755 index 0000000..5764fdc --- /dev/null +++ b/mdlinkopen @@ -0,0 +1,11 @@ +#!/bin/bash +# +# from https://facedragons.com/foss/build-a-foss-second-brain-in-vim/?utm_source=twitter&utm_medium=social&utm_campaign=ReviveOldPost +# The idea is that you call this script, type in a search term and dmenu presents a list of files in Notes that contain the +# term. Hitting enter puts it on the clip board and you can paste it into a vim file to get a link. + +SEARCHTERM=$(echo "" | dmenu) + +CHOSENFILE=$(grep -rnwli /home/lemon/Documents/Notes -e "$SEARCHTERM" | sed 's/\/home\/lemon\/Documents\/Notes\///' | dmenu -l 20) +echo $CHOSENFILE | xclip -selection c +st vim /home/lemon/Documents/Notes/"$CHOSENFILE" & diff --git a/zetrename b/zetrename new file mode 100755 index 0000000..1f73b1f --- /dev/null +++ b/zetrename @@ -0,0 +1,36 @@ +#!/bin/bash + +# Renaming files of the format YYYYMMDDHHMMSS-title text etc.md is a massive pain, so this script does it for you. + +NOTES=/home/$USER/Documents/Notes/MOD/modzet + +function usage { + echo + echo "Usage: zetrename [PATH] [NAME]" + echo " Renames a zet file, retaining original time stamp." +} + + +if [[ $# -eq 0 ]]; then + usage; exit 1 +fi + +# path must be of form /home/$USER/Notes/modzet/20220419133511-Title of file.md + +#re='^/tmp\/Notes\/modzet\/(.{14})-(.+)\.md' +re='^/home\/lemon\/Documents/Notes\/MOD\/modzet\/(.{14})-(.+)\.md' +if [[ "$1" =~ $re ]]; then + notedate=${BASH_REMATCH[1]} + oldname=${BASH_REMATCH[2]} +else + echo "Please ensure you pass an appropriate absolute path to the file to be renamed or ensure it is quoted." + exit 1 +fi + +NEW_PATH="$NOTES/$notedate-$2.md" + +echo "$NEW_PATH" + + +# rename +mv "$1" "$NEW_PATH" diff --git a/zetrename.sh b/zetrename.sh deleted file mode 100755 index e1a178d..0000000 --- a/zetrename.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/bash - -# Renaming files of the format YYYYMMDDHHMMSS-title text etc.md is a massive pain, so this script does it for you. - -NOTES=/home/$USER/Documents/Notes/modzet - -function usage { - echo - echo "Usage: zetrename [PATH] [NAME]" - echo " Renames a zet file, retaining original time stamp." -} - - -if [[ $# -eq 0 ]]; then - usage; exit 1 -fi - -# path must be of form /home/$USER/Documents/Notes/modzet/20220419133511-Title of file.md - -#re='^/tmp\/Notes\/modzet\/(.{14})-(.+)\.md' -re='^/home\/lemon\/Notes\/modzet\/(.{14})-(.+)\.md' -if [[ "$1" =~ $re ]]; then - notedate=${BASH_REMATCH[1]} - oldname=${BASH_REMATCH[2]} -else - echo "Please ensure you pass an appropriate absolute path to the file to be renamed or ensure it is quoted." - exit 1 -fi - -NEW_PATH="$NOTES/$notedate-$2.md" - -echo "$NEW_PATH" - - -# rename -mv "$1" "$NEW_PATH" -- cgit v1.2.3