mirror of
https://github.com/RyanGreenup/cadmus.git
synced 2025-04-23 11:11:51 +02:00
Compare commits
No commits in common. "master" and "1.0" have entirely different histories.
@ -1,15 +0,0 @@
|
|||||||
#+TITLE: Changelog
|
|
||||||
- Find/Search Now also supports ~org~ files
|
|
||||||
- Switched from ~mdcat~ back to ~bat~, because
|
|
||||||
+ ~bat~ works with ~.org~ without needing to use org-ruby or pandoc
|
|
||||||
+ Still having issues with ~mdcat~ not displaying results ocasionally (is this an issue with footnotes?)
|
|
||||||
- Added Rofi Menu
|
|
||||||
+ This doesn't work yet
|
|
||||||
- Rofi_find doesn't disown the browser for some reason
|
|
||||||
- Does not return the matched file name
|
|
||||||
- things typed in to rofi are not remembered after a preview
|
|
||||||
- Added a tag Py Script
|
|
||||||
+ This doesn't work yet
|
|
||||||
- using str-split to seperate filename and tag doesn't work well because
|
|
||||||
~:~ characters in the heading become a tag seperator.
|
|
||||||
- I can't use look behind because it is a non-constant length
|
|
@ -119,7 +119,7 @@ then select *index configuration* and configure recoll to have `~/Notes/MD` as t
|
|||||||
|
|
||||||
## Design Philosophy
|
## Design Philosophy
|
||||||
|
|
||||||
- ****<span style="color:rgb(90,210,90);font-family:Courier New,Courier, monospace,serif;">cadmus</span>**** acts as a menu for scripts to achieve things
|
- ****<span style="color:rgb(90,210,90);font-family:Courier New,Courier, monospace,serif;">cadmus</span>**** acts as a menu for scripts to acheive things
|
||||||
- The Actual work will be done by subscripts denoted by `description.bash`
|
- The Actual work will be done by subscripts denoted by `description.bash`
|
||||||
- The subscripts will take the note directory as an argument so they are portable and modular
|
- The subscripts will take the note directory as an argument so they are portable and modular
|
||||||
- The Arguments will be shifted and then all passed down to subfunctions
|
- The Arguments will be shifted and then all passed down to subfunctions
|
||||||
@ -196,7 +196,6 @@ This was a dependency but I switched to java script
|
|||||||
- [readability-cli](https://gitlab.com/gardenappl/readability-cli)
|
- [readability-cli](https://gitlab.com/gardenappl/readability-cli)
|
||||||
- [VNote](https://github.com/tamlok/vnote)
|
- [VNote](https://github.com/tamlok/vnote)
|
||||||
- VSCode
|
- VSCode
|
||||||
- [vscode-memo](https://github.com/svsool/vscode-memo/blob/master/CHANGELOG.md)
|
|
||||||
|
|
||||||
### PATH
|
### PATH
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
conlook () {
|
|
||||||
if [[ -f ./.config.json ]]; then
|
|
||||||
CONFIG="./config.json"
|
|
||||||
return
|
|
||||||
elif [[ CONFIG == "" ]]
|
|
||||||
if [[ "$(pwd)" == "/" ]]; then
|
|
||||||
CONFIG="~/.config/cadmus/config.json"
|
|
||||||
else
|
|
||||||
cd ..
|
|
||||||
fi
|
|
||||||
conlook
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ main() {
|
|||||||
# *** Check for Dependencies
|
# *** Check for Dependencies
|
||||||
check_for_dependencies () {
|
check_for_dependencies () {
|
||||||
|
|
||||||
for i in "${DependArray[@]}"; do
|
for i in ${DependArray[@]}; do
|
||||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -55,9 +55,9 @@ Help () {
|
|||||||
echo
|
echo
|
||||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
echo -e " \e[3m\e[1m• Usage \e[0m "
|
||||||
echo
|
echo
|
||||||
echo -e " ${script_name} [<path/to/notes>]"
|
echo -e " "${script_name}" [<path/to/notes>]"
|
||||||
echo -e " ${script_name} [-h]"
|
echo -e " "${script_name}" [-h]"
|
||||||
echo -e " ${script_name} [--help]"
|
echo -e " "${script_name}" [--help]"
|
||||||
echo
|
echo
|
||||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
||||||
echo
|
echo
|
||||||
@ -96,7 +96,7 @@ SkimNotes () {
|
|||||||
|
|
||||||
FILE="$(SkimGrep)"
|
FILE="$(SkimGrep)"
|
||||||
if [[ $FILE != "" ]]; then
|
if [[ $FILE != "" ]]; then
|
||||||
realpath "${FILE}" && exit 0
|
realpath $FILE && exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
@ -106,10 +106,8 @@ SkimNotes () {
|
|||||||
# **** Skim with Grep
|
# **** Skim with Grep
|
||||||
SkimGrep () {
|
SkimGrep () {
|
||||||
|
|
||||||
|
sk --ansi -m -c 'rg -l -t markdown --ignore-case "{}"' \
|
||||||
find . -type f \( -name "*.org" -o -name "*.md" \) |\
|
--preview "bat {} 2> /dev/null \
|
||||||
sk --ansi -m -c 'rg -l -t markdown -t org -t txt --ignore-case "{}"' \
|
|
||||||
--preview "bat --style snip {} 2> /dev/null \
|
|
||||||
--color=always --line-range :500 \
|
--color=always --line-range :500 \
|
||||||
--terminal-width 80 \
|
--terminal-width 80 \
|
||||||
--theme=TwoDark |\
|
--theme=TwoDark |\
|
||||||
|
@ -117,13 +117,11 @@ NoteSearchRecoll () {
|
|||||||
# sk -i -c 'recoll -b -t -q "ext:md" {} | cut -c 8- | sd '^' 'realpath "' | sd '$' '" --relative-to "./"' | bash ' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
# sk -i -c 'recoll -b -t -q "ext:md" {} | cut -c 8- | sd '^' 'realpath "' | sd '$' '" --relative-to "./"' | bash ' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
||||||
# Better Theme
|
# Better Theme
|
||||||
RelativePath () {
|
RelativePath () {
|
||||||
|
sk -m -i -c 'recoll -b -t -q "ext:md" {} |\
|
||||||
find . -type f \( -name "*.org" -o -name "*.md" \) |\
|
|
||||||
sk -m -i -c 'recoll -b -t -q "ext:md OR ext:org" {} |\
|
|
||||||
cut -c 8- | sed s/^/realpath\ \"/ |\
|
cut -c 8- | sed s/^/realpath\ \"/ |\
|
||||||
sed s+\$+\"\ --relative-to\ \"./\"+ | bash' \
|
sed s+\$+\"\ --relative-to\ \"./\"+ | bash' \
|
||||||
--bind pgup:preview-page-up,pgdn:preview-page-down \
|
--bind pgup:preview-page-up,pgdn:preview-page-down \
|
||||||
--preview "bat --style grid --color=always --line-range :500 \
|
--preview "bat --color=always --line-range :500 \
|
||||||
--terminal-width 80 --theme=TwoDark {+} \
|
--terminal-width 80 --theme=TwoDark {+} \
|
||||||
--italic-text=always \
|
--italic-text=always \
|
||||||
--decorations=always" \
|
--decorations=always" \
|
||||||
|
@ -1,149 +0,0 @@
|
|||||||
#! /usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
|
||||||
|
|
||||||
# * Shell Settings
|
|
||||||
set -o errexit # abort on nonzero exitstatus
|
|
||||||
set -o nounset # abort on unbound variable
|
|
||||||
set -o pipefail # don't hide errors within pipes
|
|
||||||
|
|
||||||
# * Main Function
|
|
||||||
main() {
|
|
||||||
|
|
||||||
check_for_dependencies
|
|
||||||
setVars
|
|
||||||
readFirstArgument "${@}"
|
|
||||||
NoteSearchRecoll "${@}"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# ** Helper Functions
|
|
||||||
# *** Check for Dependencies
|
|
||||||
check_for_dependencies () {
|
|
||||||
|
|
||||||
for i in ${DependArray[@]}; do
|
|
||||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** List of Dependencies
|
|
||||||
|
|
||||||
declare -a DependArray=(
|
|
||||||
"bat"
|
|
||||||
"sk"
|
|
||||||
"recoll"
|
|
||||||
"xclip"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# *** Set variables below main
|
|
||||||
setVars () {
|
|
||||||
readonly script_name=$(basename "${0}")
|
|
||||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
||||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** Print Help
|
|
||||||
Help () {
|
|
||||||
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m ${script_name}\e[0m; Helpful Shell Scripts for Markdown Notes"
|
|
||||||
echo -e " \e[1;31m--------------------------\e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " "${script_name}" [<path/relative/Dir>]"
|
|
||||||
echo -e " "${script_name}" [-h]"
|
|
||||||
echo -e " "${script_name}" [--help]"
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
|
||||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
|
||||||
echo -e " \e[1;95m Ctrl - q \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Search \e[0m with \e[0m\e[3mripgrep\e[0m"
|
|
||||||
echo -e " \e[1;93m Ctrl - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Full Path to the Clipboard"
|
|
||||||
echo -e " \e[1;93m Alt - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Relative Path to the Clipboard"
|
|
||||||
echo -e " \e[1;94m Alt - e \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Emacs"
|
|
||||||
echo -e " \e[1;94m Alt - v \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in VSCode"
|
|
||||||
echo -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " Often path names are too long to see in sk, "
|
|
||||||
echo -e " although they do provide meaningful context,"
|
|
||||||
echo -e " by displaying the pathnames relative from some directory"
|
|
||||||
echo -e " this is somewhat addressed."
|
|
||||||
echo -e " Absolute Paths are still returned for stability though."
|
|
||||||
echo
|
|
||||||
echo -e " Highlighting only works on the first word, I can't think of an easy"
|
|
||||||
echo -e " way to convert a list of values ("dog" "fox" "jump") and then perform "
|
|
||||||
echo -e " bat {} | rg -e dog -e fox -e jump " | highlight --syntax bash -O ansi
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m• Compatability \e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " This uses realpath from GNU coreutils, which doesn't"
|
|
||||||
echo -e " come with MacOS out of the box"
|
|
||||||
echo
|
|
||||||
echo -e " This doesn't work: "
|
|
||||||
echo -e ' rg "$(echo {cq} | rg "$(echo $var | sed s+\ +\|+g )") ' | highlight --syntax bash -O ansi
|
|
||||||
echo
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# *** Read First Argument
|
|
||||||
readFirstArgument () {
|
|
||||||
|
|
||||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "" ]]; then
|
|
||||||
Help && exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
# *** Note Recoll Search
|
|
||||||
NoteSearchRecoll () {
|
|
||||||
|
|
||||||
## Change directory if One was specified, exit if no directory exists
|
|
||||||
cd "${1}"
|
|
||||||
|
|
||||||
|
|
||||||
## I really really like this one!!
|
|
||||||
## Display Path Relative to Notes Dir
|
|
||||||
# sk -i -c 'recoll -b -t -q "ext:md" {} | cut -c 8- | sd '^' 'realpath "' | sd '$' '" --relative-to "./"' | bash ' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
|
||||||
# Better Theme
|
|
||||||
RelativePath () {
|
|
||||||
sk -m -i -c 'recoll -b -t -q "ext:md OR ext:org" {} |\
|
|
||||||
cut -c 8- | sed s/^/realpath\ \"/ |\
|
|
||||||
sed s+\$+\"\ --relative-to\ \"./\"+ | bash' \
|
|
||||||
--bind pgup:preview-page-up,pgdn:preview-page-down \
|
|
||||||
<<<<<<< HEAD
|
|
||||||
--preview "bat --style grid --color=always --line-range :500 \
|
|
||||||
--terminal-width 80 --theme=TwoDark {+} \
|
|
||||||
--italic-text=always \
|
|
||||||
--decorations=always" \
|
|
||||||
=======
|
|
||||||
--preview "mdcat {+}" \
|
|
||||||
>>>>>>> ffa1640104ce9c097d1233a7d5745cd95fb9f7fb
|
|
||||||
--color=fg:#f8f8f2,bg:-1,matched:#6272a4,current_fg:#50fa7b,current_bg:#381070,border:#ff79c6,prompt:#bd93f9,query:#bd93f9,marker:#f1fa8c,header:#f1fa8c
|
|
||||||
}
|
|
||||||
RELATIVE_PATH="$(RelativePath)"
|
|
||||||
|
|
||||||
echo "${RELATIVE_PATH}" | xargs realpath
|
|
||||||
## ## Display full path
|
|
||||||
## sk -i -c 'recoll -b -t -q "ext:md {}" | cut -c 8-' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula {}"
|
|
||||||
##
|
|
||||||
##
|
|
||||||
## ## Display only file name
|
|
||||||
## ##
|
|
||||||
## sk -i -c 'recoll -b -t -q "ext:md" | cut -c 8- | sd \'^\' \'"\' | sd \'$\' \'"\' | sd \'^\' \'basename \' | bash' --bind pgup:preview-page-up,pgdn:preview-page-down --preview "echo {} | xargs fd | xargs bat --color=always --line-range :500 --terminal-width 80 --theme=Dracula "
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# * Call Main Function
|
|
||||||
main "${@}"
|
|
101
bin/cadmus
101
bin/cadmus
@ -18,8 +18,6 @@ set -o nounset
|
|||||||
# don't hide errors within pipes
|
# don't hide errors within pipes
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
# readonly EDITOR="ema"
|
|
||||||
readonly EDITOR="xdg-open"
|
|
||||||
|
|
||||||
# * Main Functions
|
# * Main Functions
|
||||||
|
|
||||||
@ -99,7 +97,6 @@ function mainHelp() {
|
|||||||
echo -e " 🔍 \e[1;93m \e[4mf\e[0m\e[1;93mind \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
|
echo -e " 🔍 \e[1;93m \e[4mf\e[0m\e[1;93mind \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
|
||||||
echo -e " 🔎 \e[1;32m \e[4ms\e[0m\e[1;32mearch \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Search through Notes using Recoll"
|
echo -e " 🔎 \e[1;32m \e[4ms\e[0m\e[1;32mearch \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Search through Notes using Recoll"
|
||||||
echo -e " 🏷 \e[1;33m \e[4mt\e[0m\e[1;33mags \e[0m \e[1;34m ┊┊┊ 📁\e[0m Use TMSU to work with tags"
|
echo -e " 🏷 \e[1;33m \e[4mt\e[0m\e[1;33mags \e[0m \e[1;34m ┊┊┊ 📁\e[0m Use TMSU to work with tags"
|
||||||
echo -e " 📖 \e[1;33m \e[4mr\e[0m\e[1;33mofi \e[0m \e[1;34m ┊┊┊ 📁\e[0m Use ROFI instead of fzf (WIP) "
|
|
||||||
echo -e " 🔧 \e[1;34m \e[4mto\e[0m\e[1;34mols \e[0m \e[1;34m ┊┊┊ 📁\e[0m Tools for Editing"
|
echo -e " 🔧 \e[1;34m \e[4mto\e[0m\e[1;34mols \e[0m \e[1;34m ┊┊┊ 📁\e[0m Tools for Editing"
|
||||||
echo -e " 📝 \e[1;35m \e[4me\e[0m\e[1;35mxport \e[0m \e[1;34m ┊┊┊ 📁\e[0m Export Notes to Different Formats "
|
echo -e " 📝 \e[1;35m \e[4me\e[0m\e[1;35mxport \e[0m \e[1;34m ┊┊┊ 📁\e[0m Export Notes to Different Formats "
|
||||||
echo -e " ⎋ \e[1;36m \e[4mc\e[0m\e[1;36monvert \e[0m \e[1;34m ┊┊┊ 📁\e[0m Convert Clipboard Contents to Different Formats "
|
echo -e " ⎋ \e[1;36m \e[4mc\e[0m\e[1;36monvert \e[0m \e[1;34m ┊┊┊ 📁\e[0m Convert Clipboard Contents to Different Formats "
|
||||||
@ -156,8 +153,6 @@ arguments () {
|
|||||||
;;
|
;;
|
||||||
search|s) shift; NoteSearch "${NOTES_DIR}" ${@:-}
|
search|s) shift; NoteSearch "${NOTES_DIR}" ${@:-}
|
||||||
;;
|
;;
|
||||||
rofi|r) shift; RofiMenu ${@:-}
|
|
||||||
;;
|
|
||||||
tags|t) shift; CadmusTags ${@:-}
|
tags|t) shift; CadmusTags ${@:-}
|
||||||
;;
|
;;
|
||||||
tools|to) shift; CadmusTools "${@:-}"
|
tools|to) shift; CadmusTools "${@:-}"
|
||||||
@ -200,7 +195,7 @@ function NoteFind() {
|
|||||||
## the keybindings to emacsclient.
|
## the keybindings to emacsclient.
|
||||||
# Using XDG-OPEN
|
# Using XDG-OPEN
|
||||||
# echo "${FILES}" | sed s/^/xdg-open\ \"/ | sed s/$/\"/ | bash
|
# echo "${FILES}" | sed s/^/xdg-open\ \"/ | sed s/$/\"/ | bash
|
||||||
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 "${EDITOR}"
|
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 xdg-open
|
||||||
|
|
||||||
# # Getting the .desktop file and cutting off the Extension
|
# # Getting the .desktop file and cutting off the Extension
|
||||||
# dex "$(xdg-mime query default text/markdown)" $FILES
|
# dex "$(xdg-mime query default text/markdown)" $FILES
|
||||||
@ -221,61 +216,7 @@ function NoteSearch() {
|
|||||||
|
|
||||||
## Only try and open something that is non-empty
|
## Only try and open something that is non-empty
|
||||||
if [ "$FILES" != "" ]; then
|
if [ "$FILES" != "" ]; then
|
||||||
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 "${EDITOR}"
|
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 xdg-open
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# *** RofiMenu
|
|
||||||
function RofiMenu() {
|
|
||||||
|
|
||||||
[[ -z "${1:-}" ]] && RofiHelp && exit 0
|
|
||||||
|
|
||||||
while test $# -gt 0
|
|
||||||
do
|
|
||||||
case "$1" in
|
|
||||||
search) shift; "${script_dir}"/rofi_search.sh "${NOTES_DIR}" && exit 0
|
|
||||||
;;
|
|
||||||
find) shift; "${script_dir}"/rofi_find.sh "${NOTES_DIR}" && exit 0
|
|
||||||
;;
|
|
||||||
--*) >&2 echo "bad option $1"
|
|
||||||
;;
|
|
||||||
*) >&2 echo -e "argument \e[1;35m${1}\e[0m has no definition."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** Rofi Help
|
|
||||||
function RofiHelp() {
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m Cadmus Rofi\e[0m; Use Rofi and Browser to Search/Find and Preview"
|
|
||||||
echo -e " \e[1;31m -------------------------\e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m• Notes\e[0m "
|
|
||||||
echo
|
|
||||||
echo
|
|
||||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
|
||||||
echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
|
||||||
echo -e " \e[1;93m find \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Find Notes based on FileName"
|
|
||||||
echo -e " \e[1;32m search \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Create Tags with TMSU"
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
# *** Note Search
|
|
||||||
|
|
||||||
function NoteSearch() {
|
|
||||||
COMMAND="${script_dir}/NoteRecollSearch.sh"
|
|
||||||
echo "Running "${COMMAND}" "${1}""
|
|
||||||
|
|
||||||
FILES="$("${COMMAND}" "${@:-}")"
|
|
||||||
|
|
||||||
## Only try and open something that is non-empty
|
|
||||||
if [ "$FILES" != "" ]; then
|
|
||||||
echo "${FILES}" | sed -e s+^+\"+ -e s+$+\"+ | xargs -n 1 "${EDITOR}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,18 +298,15 @@ CadmusTools () {
|
|||||||
;;
|
;;
|
||||||
webtitle) shift; "${script_dir}/tools/PrintWebTitle.sh" "$(CLIP_OUT)" | CLIP_IN
|
webtitle) shift; "${script_dir}/tools/PrintWebTitle.sh" "$(CLIP_OUT)" | CLIP_IN
|
||||||
;;
|
;;
|
||||||
backlinks) shift; "${script_dir}/tools/List-Backlinks.sh" "$(CLIP_OUT)" "${NOTES_DIR}" ${@:-} && exit 0
|
backlinks) shift; "${script_dir}/tools/List-Backlinks.sh" "$(CLIP_OUT)" ${@:-} && exit 0
|
||||||
;;
|
;;
|
||||||
link) shift; "${script_dir}/tools/LinkMarkdownNotes.sh" "${NOTES_DIR}" "$(CLIP_OUT)" | CLIP_IN && exit 0
|
link) shift; "${script_dir}/tools/LinkMarkdownNotes.sh" "${NOTES_DIR}" "$(CLIP_OUT)" | CLIP_IN && exit 0
|
||||||
;;
|
;;
|
||||||
fix) shift; "${script_dir}/tools/fixLink.sh" "${NOTES_DIR}" && exit 0
|
fix) shift; "${script_dir}/tools/fixLink.sh" "${NOTES_DIR}" && exit 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
unused-attachments) shift; node "${script_dir}/tools/print_unused_attachments.js" "${NOTES_DIR}" && exit 0
|
|
||||||
;;
|
|
||||||
page-import) shift; CLIP_OUT | xargs curl | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit 0
|
page-import) shift; CLIP_OUT | xargs curl | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit 0
|
||||||
;;
|
;;
|
||||||
random) shift; find "${NOTES_DIR}" -name '*.md' | shuf -n 1 | xargs "${EDITOR}" && exit 0
|
random) shift; find "${NOTES_DIR}" -name '*.md' | shuf -n 1 | xargs xdg-open && exit 0
|
||||||
;;
|
;;
|
||||||
rename) shift; CadmusRename "${NOTES_DIR}" && exit 0
|
rename) shift; CadmusRename "${NOTES_DIR}" && exit 0
|
||||||
;;
|
;;
|
||||||
@ -412,13 +350,12 @@ function ToolsHelp() {
|
|||||||
echo -e " \\ ..................................(back slash)"
|
echo -e " \\ ..................................(back slash)"
|
||||||
echo
|
echo
|
||||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||||
echo -e " ..................\e[1;34m....┊┊┊\e[0m........................................... "
|
echo -e " ..................\e[1;34m┊┊┊\e[0m........................................... "
|
||||||
echo -e " \e[1;93m new \e[0m \e[1;34m ┊┊┊ \e[0m Starts an interactive prompt to make a new note"
|
echo -e " \e[1;93m new \e[0m \e[1;34m ┊┊┊ \e[0m Starts an interactive prompt to make a new note"
|
||||||
echo -e " \e[1;93m webtitle \e[0m \e[1;34m ┊┊┊ \e[0m✀ Transforms the Clipboard 📋 to a Link"
|
echo -e " \e[1;93m webtitle \e[0m \e[1;34m ┊┊┊ \e[0m✀ Transforms the Clipboard 📋 to a Link"
|
||||||
echo -e " \e[1;93m backlinks \e[0m \e[1;34m ┊┊┊ \e[0m✀ Takes the Abs Path of a Note from the Clipboard 📋"
|
echo -e " \e[1;93m backlinks \e[0m \e[1;34m ┊┊┊ \e[0m✀ Takes the Abs Path of a Note from the Clipboard 📋"
|
||||||
echo -e " \e[1;93m \e[0m \e[1;34m ┊┊┊ \e[0m and prints out backlinks (Abs Path)"
|
echo -e " \e[1;93m \e[0m \e[1;34m ┊┊┊ \e[0m and prints out backlinks (Abs Path)"
|
||||||
echo -e " \e[1;93m fix \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Fix the relative path in the clipboard 📋 "
|
echo -e " \e[1;93m fix \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Fix the relative path in the clipboard 📋 "
|
||||||
echo -e " \e[1;93m unused-attachments \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Print unused attachments, not working yet "
|
|
||||||
echo -e " \e[1;93m link \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Generate a link to another note from the current in the clipboard"
|
echo -e " \e[1;93m link \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Generate a link to another note from the current in the clipboard"
|
||||||
echo -e " \e[1;32m page-import \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Transform Clipboard from URL to corresponding Markdown"
|
echo -e " \e[1;32m page-import \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Transform Clipboard from URL to corresponding Markdown"
|
||||||
echo -e " \e[1;32m random \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Open a Random Note in the Default program"
|
echo -e " \e[1;32m random \e[0m \e[1;34m ┊┊┊ 🎆 \e[0m Open a Random Note in the Default program"
|
||||||
@ -485,7 +422,7 @@ makeNewNote () {
|
|||||||
echo -e "---\n" >> "${FILE}"
|
echo -e "---\n" >> "${FILE}"
|
||||||
echo -e "# "${NAME}"" >> "${FILE}"
|
echo -e "# "${NAME}"" >> "${FILE}"
|
||||||
|
|
||||||
mdcat "${FILE}"
|
bat "${FILE}"
|
||||||
echo -e "Succesfully Created:\n "${FILE}""
|
echo -e "Succesfully Created:\n "${FILE}""
|
||||||
nvim + "${FILE}"
|
nvim + "${FILE}"
|
||||||
|
|
||||||
@ -555,7 +492,7 @@ CadmusExport () {
|
|||||||
;;
|
;;
|
||||||
html) shift; pandocExport html --mathml --self-contained -c "${script_dir}"'/resources/pandoc.css' && exit 0
|
html) shift; pandocExport html --mathml --self-contained -c "${script_dir}"'/resources/pandoc.css' && exit 0
|
||||||
;;
|
;;
|
||||||
html-dir) shift; pandocExport html --mathjax -c "${script_dir}"'/resources/pandoc.css' && exit 0
|
html-dir) shift; pandocExport html --katex -c "${script_dir}"'/resources/pandoc.css' && exit 0
|
||||||
;;
|
;;
|
||||||
page-import) shift; CLIP_OUT | xargs curl | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit 0
|
page-import) shift; CLIP_OUT | xargs curl | pandoc -f html -t markdown_github+tex_math_dollars --atx-headers | CLIP_IN && exit 0
|
||||||
;;
|
;;
|
||||||
@ -590,21 +527,12 @@ pandocExport () { # $1 is extension; $2+ are options for pandoc
|
|||||||
echo -e " \e[1;94m Output to: \e[1;32m "${OUTDIR}"/"${FILEOUT}"\e[0m"
|
echo -e " \e[1;94m Output to: \e[1;32m "${OUTDIR}"/"${FILEOUT}"\e[0m"
|
||||||
echo
|
echo
|
||||||
echo -e " \e[1;94m Performing: \e[0m"
|
echo -e " \e[1;94m Performing: \e[0m"
|
||||||
echo " pandoc -s "${FILE}" --mathjax ${@:-} --extract-media="${OUTDIR}/Media" -o "${OUTDIR}"/"${FILEOUT} | highlight --syntax bash -O ansi
|
echo " pandoc -s "${FILE}" ${@:-} --extract-media="${OUTDIR}/media" -o "${OUTDIR}"/"${FILEOUT} | highlight --syntax bash -O ansi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
## Media must have first letter capitalised for mediawiki
|
pandoc -s "${FILE}" ${@:-} --extract-media="${OUTDIR}/media" -o "${OUTDIR}"/"${FILEOUT}" || exit 7
|
||||||
## HTML2Wiki wants zip file
|
xdg-open "${OUTDIR}"/"${FILEOUT}"
|
||||||
|
|
||||||
pandoc -s "${FILE}" ${@:-} --extract-media="${OUTDIR}/Media" -o "${OUTDIR}"/"${FILEOUT}" || exit 7
|
|
||||||
cd "${OUTDIR}"
|
|
||||||
## Run it a second time so extracted media is relative not absolute
|
|
||||||
## It seems mathjax only works here, not katex :shrug:
|
|
||||||
pandoc -f -s --mathjax "${FILEOUT}" ${@:-} --extract-media="Media" -o "${FILEOUT}" || echo "" # This might fail for PDF's, don't exit
|
|
||||||
## Zip everything up as well
|
|
||||||
zip -r "$(echo ${FILE} | cut -f 1 -d '.')".zip *
|
|
||||||
"${EDITOR}" "${OUTDIR}"/"${FILEOUT}"
|
|
||||||
cd -
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# **** Help
|
# **** Help
|
||||||
@ -618,7 +546,8 @@ function ExportHelp () {
|
|||||||
echo -e " This does not work for multiple selections (yet) so avoid pressing"
|
echo -e " This does not work for multiple selections (yet) so avoid pressing"
|
||||||
echo -e " TAB to try and export multiple files, it won't work"
|
echo -e " TAB to try and export multiple files, it won't work"
|
||||||
echo
|
echo
|
||||||
echo -e " The links in exports are made relative, by using a second call to pandoc"
|
echo -e " The links in exports are not relative, I don't know why,"
|
||||||
|
echo -e " I need to fix this because it's really really inconvenient."
|
||||||
echo
|
echo
|
||||||
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
echo -e " \e[1;91m \e[1m Command \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
||||||
echo -e " ...............\e[1;34m┊┊┊\e[0m........................................... "
|
echo -e " ...............\e[1;34m┊┊┊\e[0m........................................... "
|
||||||
@ -631,7 +560,6 @@ function ExportHelp () {
|
|||||||
echo -e " \e[1;32m html \e[0m \e[1;34m ┊┊┊\e[0m Make a self-contained MathML HTML (firefox/safari only)"
|
echo -e " \e[1;32m html \e[0m \e[1;34m ┊┊┊\e[0m Make a self-contained MathML HTML (firefox/safari only)"
|
||||||
echo -e " \e[1;32m html-dir \e[0m \e[1;34m ┊┊┊\e[0m Make a directory of HTML+images (for importing to Mediawiki)"
|
echo -e " \e[1;32m html-dir \e[0m \e[1;34m ┊┊┊\e[0m Make a directory of HTML+images (for importing to Mediawiki)"
|
||||||
echo -e " \e[1;32m md \e[0m \e[1;34m ┊┊┊\e[0m Export markdown and images to directory"
|
echo -e " \e[1;32m md \e[0m \e[1;34m ┊┊┊\e[0m Export markdown and images to directory"
|
||||||
echo -e " \e[1;32m org \e[0m \e[1;34m ┊┊┊\e[0m Export as org-mode with images to directory"
|
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,13 +755,14 @@ subHelp () {
|
|||||||
echo -e "\e[1;35m -------------------------\e[0m "
|
echo -e "\e[1;35m -------------------------\e[0m "
|
||||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Find \e[0m"
|
echo -e " \e[1;94m\e[3m\e[1m Cadmus Find \e[0m"
|
||||||
echo -e "\e[1;35m -------------------------\e[0m "
|
echo -e "\e[1;35m -------------------------\e[0m "
|
||||||
"${script_dir}/NoteFind.sh"
|
NoteFind.sh -h
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
echo -e "\e[1;35m -------------------------\e[0m "
|
echo -e "\e[1;35m -------------------------\e[0m "
|
||||||
echo -e " \e[1;94m\e[3m\e[1m Cadmus Search\e[0m"
|
echo -e " \e[1;94m\e[3m\e[1m Cadmus Search\e[0m"
|
||||||
echo -e "\e[1;35m -------------------------\e[0m "
|
echo -e "\e[1;35m -------------------------\e[0m "
|
||||||
"${script_dir}/NoteRecollSearch.sh"
|
NoteRecollSearch.sh -h
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
205
bin/rofi_find.sh
205
bin/rofi_find.sh
@ -1,205 +0,0 @@
|
|||||||
#! /usr/bin/env bash
|
|
||||||
#
|
|
||||||
# Author: Ryan Greenup <ryan.greenup@protonmail.com>
|
|
||||||
|
|
||||||
# * Shell Settings
|
|
||||||
set -o errexit # abort on nonzero exitstatus
|
|
||||||
set -o nounset # abort on unbound variable
|
|
||||||
set -o pipefail # don't hide errors within pipes
|
|
||||||
|
|
||||||
# * Main Function
|
|
||||||
main() {
|
|
||||||
|
|
||||||
check_for_dependencies
|
|
||||||
setVars
|
|
||||||
readFirstArgument "${@}"
|
|
||||||
rofi_over_Notes "${@}"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# ** Helper Functions
|
|
||||||
# *** Check for Dependencies
|
|
||||||
check_for_dependencies () {
|
|
||||||
|
|
||||||
for i in ${DependArray[@]}; do
|
|
||||||
command -v "$i" >/dev/null 2>&1 || { echo >&2 "I require $i but it's not installed. Aborting."; exit 1; }
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** List of Dependencies
|
|
||||||
|
|
||||||
declare -a DependArray=(
|
|
||||||
"rofi"
|
|
||||||
"rg"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# *** Set variables below main
|
|
||||||
setVars () {
|
|
||||||
readonly script_name=$(basename "${0}")
|
|
||||||
readonly script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
|
||||||
IFS=$'\t\n' # Split on newlines and tabs (but not on spaces)
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** Print Help
|
|
||||||
Help () {
|
|
||||||
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1mNoteFind.sh \e[0m; Helpful Shell Scripts for Markdown Notes"
|
|
||||||
echo -e " \e[1;31m--------------------------\e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m\e[1m• Usage \e[0m "
|
|
||||||
echo
|
|
||||||
echo -e " "${script_name}" [<path/to/notes>]"
|
|
||||||
echo -e " "${script_name}" [-h]"
|
|
||||||
echo -e " "${script_name}" [--help]"
|
|
||||||
echo
|
|
||||||
echo -e " \e[3m By Design: No Options; No other Arguments\e[0m"
|
|
||||||
echo
|
|
||||||
# echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
|
||||||
# echo
|
|
||||||
# echo
|
|
||||||
# echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
|
||||||
# echo -e " ..............\e[1;34m┊┊┊\e[0m........................................... "
|
|
||||||
# echo -e " \e[1;95m Ctrl - q \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Search \e[0m with \e[0m\e[3mripgrep\e[0m"
|
|
||||||
# echo -e " \e[1;93m Ctrl - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Full Path to the Clipboard"
|
|
||||||
# echo -e " \e[1;93m Alt - w \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Copy \e[0m the Relative Path to the Clipboard"
|
|
||||||
# echo -e " \e[1;94m Alt - e \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Emacs"
|
|
||||||
# echo -e " \e[1;94m Alt - v \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in VSCode"
|
|
||||||
# echo -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
|
||||||
# echo
|
|
||||||
|
|
||||||
# echo -e " \e[3m\e[1m• Compatability \e[0m "
|
|
||||||
# echo
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# *** Read First Argument
|
|
||||||
readFirstArgument () {
|
|
||||||
|
|
||||||
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]] || [[ "${1:-}" == "" ]]; then
|
|
||||||
Help && exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
# *** Skim and Grep, the important stuff
|
|
||||||
#
|
|
||||||
rofi_over_Notes () {
|
|
||||||
|
|
||||||
## Change directory if One was specified, exit if no directory exists
|
|
||||||
|
|
||||||
cd "${1}"
|
|
||||||
|
|
||||||
FILE="$(RofiFind)"
|
|
||||||
|
|
||||||
if [[ $FILE != "" ]]; then
|
|
||||||
realpath $FILE && exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** Skim with Grep
|
|
||||||
RofiFind () {
|
|
||||||
|
|
||||||
## Change directory if One was specified, exit if no directory exists
|
|
||||||
|
|
||||||
# I took this bit from https://github.com/davatorium/rofi/issues/997
|
|
||||||
# Not totally sure how it works but it does :shrug
|
|
||||||
|
|
||||||
## Set Variables
|
|
||||||
local selected
|
|
||||||
local string
|
|
||||||
selected="${1:-}"
|
|
||||||
|
|
||||||
TEMP_DIR="/tmp/cadmus_rofi_preview"
|
|
||||||
mkdir -p "${TEMP_DIR}"
|
|
||||||
|
|
||||||
# schemes="$(fd '\.org$')" # TODO Only look at org-mode files (hmmmm)
|
|
||||||
schemes="$(find ./ -name '*\.org' -or -name '*\.md')"
|
|
||||||
lines=$(printf '%s\n' "${schemes}" | wc -l)
|
|
||||||
menu=$(printf '%s\n' "${schemes}" | rofi -matching fuzzy -location 1 -kb-row-up "" -kb-row-down "" -kb-custom-1 "Up" -kb-custom-2 "Down" -format 'd:s' -dmenu -selected-row $selected)
|
|
||||||
|
|
||||||
exit_code=$?
|
|
||||||
|
|
||||||
selected="${menu%:*}"
|
|
||||||
string="${menu##*:}"
|
|
||||||
|
|
||||||
case "${exit_code}" in
|
|
||||||
"1") exit 0;;
|
|
||||||
"0") PRINT_OUT "${string}" & disown;;
|
|
||||||
"10")
|
|
||||||
if [[ $selected == "1" ]]; then
|
|
||||||
foo_selected="${lines}"
|
|
||||||
call="3"
|
|
||||||
else
|
|
||||||
foo_selected="$(echo -e $(( ${selected} - 1 )))";
|
|
||||||
call=$(echo $(( ${selected} - 2 )))
|
|
||||||
fi
|
|
||||||
foo="$(printf '%s' "${schemes}" | sed -n "${foo_selected}"p)";
|
|
||||||
PRINT_OUT "${foo}" & disown;;
|
|
||||||
"11")
|
|
||||||
if [[ "${selected}" -ge "${lines}" ]]; then
|
|
||||||
foo_selected="1"
|
|
||||||
call="0"
|
|
||||||
else
|
|
||||||
foo_selected="$(echo -e $(( ${selected} + 1 )))";
|
|
||||||
call="${selected}"
|
|
||||||
fi
|
|
||||||
foo="$(printf '%s' "${schemes}" | sed -n "${foo_selected}"p)";
|
|
||||||
PRINT_OUT "${foo}" & disown
|
|
||||||
esac
|
|
||||||
|
|
||||||
RofiFind "${call}"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
# **** Convert the File with Pandoc and Show in Browser
|
|
||||||
PRINT_OUT () {
|
|
||||||
FILEPATH="$(realpath ${1})"
|
|
||||||
FILEPATH_NO_EXT="$(realpath ${1} | cut -f 1 -d '.')"
|
|
||||||
DIRECTORY="$(dirname ${FILEPATH}})"
|
|
||||||
NAME="$(basename ${@} | cut -f 1 -d '.')"
|
|
||||||
|
|
||||||
BROWSER="chromium"
|
|
||||||
|
|
||||||
# Simpler calls
|
|
||||||
# pandoc -f org -t html "${FILEPATH}" --quiet | cat
|
|
||||||
|
|
||||||
function pandoc_browser() {
|
|
||||||
#pandoc -f org -t html "${FILEPATH}" -A /home/ryan/Templates/CSS/gitOrgWrapped.css --mathjax -s --quiet -o "/dev/shm/${NAME}.html" && \
|
|
||||||
pandoc -t html "${FILEPATH}" --extract-media="${TEMP_DIR}/media_${NAME}" -A /home/ryan/Templates/CSS/gitOrgWrapped.css --katex -s --quiet -o "${TEMP_DIR}/${NAME}.html" && \
|
|
||||||
"${BROWSER}" "${TEMP_DIR}/${NAME}.html" > /dev/null & disown # Chromium is faster than firefox
|
|
||||||
}
|
|
||||||
|
|
||||||
## By caching the export in /dev/shm/ chrome will just go back to the last tab (quicker)
|
|
||||||
## and pandoc won't reconvert unnecessarily (quicker)
|
|
||||||
## Given that most of the time is spent looking and reading this makes a lot of sense
|
|
||||||
|
|
||||||
if [ "${FILEPATH}" -nt "${TEMP_DIR}/${NAME}.html" ]; then
|
|
||||||
# The Live_Reload_JS lets me reload this, otherwise do not disown this process
|
|
||||||
pandoc_browser & disown
|
|
||||||
else
|
|
||||||
"${BROWSER}" "${TEMP_DIR}/${NAME}.html" & disown
|
|
||||||
fi
|
|
||||||
|
|
||||||
# I tried this with org-ruby, no luck though for latex though
|
|
||||||
# Org-ruby is much faster than pandoc
|
|
||||||
# /home/ryan/.gem/ruby/2.7.0/bin/org-ruby "${FILEPATH}" -t html > /dev/shm/mpv.html
|
|
||||||
# cat /home/ryan/Templates/mathjax >> /dev/shm/mpv.html
|
|
||||||
# cat /home/ryan/Templates/CSS/gitOrgWrapped.css >> /dev/shm/mpv.html
|
|
||||||
# chromium /dev/shm/mpv.html & disown
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# * Call Main Function
|
|
||||||
main "${@}"
|
|
@ -1,73 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
## This doesn't work yet, the problem is at line 21, it identifies a lot of crap
|
|
||||||
## as tags if there are ~:~ characters in the heading.
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import glob
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
# Set Working Directory
|
|
||||||
try:
|
|
||||||
os.chdir(sys.argv[1])
|
|
||||||
# os.chdir((os.getenv('HOME')))
|
|
||||||
# os.chdir('Notes/Org/')
|
|
||||||
except:
|
|
||||||
print("Exiting; Unable to Access Directory " + str(sys.argv[1]))
|
|
||||||
|
|
||||||
ripgrep_command = ['rg', '--vimgrep', '-t', 'org', r"^\*+\s.*\s+:.+:"]
|
|
||||||
grep_results = subprocess.run(ripgrep_command, stdout=subprocess.PIPE).stdout.decode('utf-8')
|
|
||||||
|
|
||||||
# TODO Identifies any `:` in a heading as tag seperator, I can't extract
|
|
||||||
# org-mode tags until I fix this
|
|
||||||
grep_results = str(grep_results).split('\n')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Match org-mode files
|
|
||||||
def printOrgFiles(dir):
|
|
||||||
os.chdir(dir)
|
|
||||||
files = os.listdir()
|
|
||||||
orgFiles = []
|
|
||||||
for file in files:
|
|
||||||
pattern = re.compile('.+\.org$')
|
|
||||||
if re.match(pattern, file) and not re.match(pattern, file):
|
|
||||||
orgFiles.append(file)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Search for Tags in org-files
|
|
||||||
|
|
||||||
lines = {
|
|
||||||
'filename': [],
|
|
||||||
'lineNumber': [],
|
|
||||||
'title': [],
|
|
||||||
'tags': []
|
|
||||||
}
|
|
||||||
|
|
||||||
for line in grep_results:
|
|
||||||
line_list = str(line).split(':')
|
|
||||||
try:
|
|
||||||
lines['filename'].append(line_list[0])
|
|
||||||
lines['lineNumber'].append(line_list[1])
|
|
||||||
lines['title'].append(line_list[3]) # 2 is column number, we just want first
|
|
||||||
lines['tags'].append(list(line_list[4:-1])) # make sure that a single tag is still a list for consistency
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
# print('missing value, skip line')
|
|
||||||
# print('---')
|
|
||||||
# print(lines)
|
|
||||||
|
|
||||||
# Print the filename, tag and line number
|
|
||||||
|
|
||||||
for i in range(len(lines['lineNumber'])):
|
|
||||||
try:
|
|
||||||
filename = lines['filename'][i]
|
|
||||||
lineNumber = lines['lineNumber'][i]
|
|
||||||
tags = lines['tags'][i]
|
|
||||||
# print(filename + ',' + lineNumber + ',' + str(tags))
|
|
||||||
print("tmsu tag '" + filename + "' " + str(tags).replace('[', '').replace(']',''))
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
# Do nothing in exception for clean STDOUT
|
|
@ -1,20 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
command -v rg >/dev/null 2>&1 || { echo >&2 "I require ripgrep but it's not installed. Aborting."; exit 1; }
|
command -v rg >/dev/null 2>&1 || { echo >&2 "I require ripgrep but it's not installed. Aborting."; exit 1; }
|
||||||
command -v sd >/dev/null 2>&1 || { echo >&2 "I require sd (sed replacement) but it's not installed. Aborting."; exit 1; }
|
command -v sd >/dev/null 2>&1 || { echo >&2 "I require sd (sed replacement) but it's not installed. Aborting."; exit 1; }
|
||||||
command -v xclip >/dev/null 2>&1 || { echo >&2 "I require xclip but it's not installed. Aborting."; exit 1; }
|
command -v xclip >/dev/null 2>&1 || { echo >&2 "I require xclip but it's not installed. Aborting."; exit 1; }
|
||||||
|
|
||||||
|
|
||||||
term=$(basename "${1}" | cut -f 1 -d '.')
|
term=$(basename "${1}" | cut -f 1 -d '.')
|
||||||
DIR="${2}"
|
|
||||||
|
|
||||||
|
|
||||||
rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
|
rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
|
||||||
"${DIR}" \
|
~/Notes/MD/notes \
|
||||||
-t markdown -ol
|
-t markdown -ol
|
||||||
# ~/Notes/MD/notes \
|
|
||||||
|
|
||||||
## If you want to preview the Backlinks
|
## If you want to preview the Backlinks
|
||||||
## rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
|
## rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
|
||||||
|
@ -91,8 +91,9 @@ ${BLUE} $arglink
|
|||||||
|
|
||||||
${NC} It's description is\n"
|
${NC} It's description is\n"
|
||||||
|
|
||||||
title=$(wget -qO- $arglink |\
|
title=$(wget -qO- $arglink |
|
||||||
rg -m 1 -o --pcre2 '(?<=<title>)(.*)(?=</title>)' )
|
perl -l -0777 -ne 'print $1 if /<title.*?>\s*(.*?)\s*<\/title/si' |
|
||||||
|
recode html..)
|
||||||
|
|
||||||
>&2 echo $title
|
>&2 echo $title
|
||||||
|
|
||||||
|
@ -1,108 +0,0 @@
|
|||||||
// test this with node print_unused_attachments.js | xargs rg
|
|
||||||
// It doesn't seem to work.
|
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////
|
|
||||||
// ////////// Load Libraries ////////////////////////////////
|
|
||||||
// //////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
|
||||||
// const yamlFront = require('yaml-front-matter');
|
|
||||||
let debugFlag = false;
|
|
||||||
let glob = require('glob');
|
|
||||||
|
|
||||||
function main() {
|
|
||||||
change_directory();
|
|
||||||
attachments = get_file_names()[0];
|
|
||||||
notes = get_file_names()[1];
|
|
||||||
unused_attachments = find_unused_attachments(attachments, notes);
|
|
||||||
print(unused_attachments)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function change_directory() {
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
/////////// Change Directory ///////////////////////////////
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
if (process.argv[2] == undefined) {
|
|
||||||
const path = "./";
|
|
||||||
if (debugFlag) {
|
|
||||||
console.log(`No Path Detected, using this directory ${process.argv[1]}`)
|
|
||||||
console.log("Remember to use $HOME not ~")
|
|
||||||
}
|
|
||||||
} else if (process.argv[2] == "-h" | process.argv[2] == "--help") {
|
|
||||||
console.log("\nProvide the Directory of MD Notes as the First Argument")
|
|
||||||
console.log("Otherwise the current directory, ./, will be used.\n")
|
|
||||||
console.log("No notes will not lead to any warning")
|
|
||||||
console.log("This is necessary so as to not be dangerous when | bash\n")
|
|
||||||
} else {
|
|
||||||
const path = process.argv[2];
|
|
||||||
process.chdir(path);
|
|
||||||
if (debugFlag) {
|
|
||||||
console.log(`Using Specified Directory ${process.argv[2]}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_file_names() {
|
|
||||||
// //////////////////////////////////////////////////////////
|
|
||||||
// ////////////// Get File Names/////////////////////////////
|
|
||||||
// //////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
let att_extensions = [
|
|
||||||
"./**/*.png",
|
|
||||||
"./**/*.jpeg",
|
|
||||||
"./**/*.jpg",
|
|
||||||
"./**/*.svg"
|
|
||||||
]
|
|
||||||
|
|
||||||
let note_extensions = [
|
|
||||||
"./**/*.md",
|
|
||||||
"./**/*.org",
|
|
||||||
"./**/*.txt",
|
|
||||||
"./**/*.html",
|
|
||||||
"./**/*.tex"
|
|
||||||
]
|
|
||||||
|
|
||||||
var attFilePathList = [];
|
|
||||||
var noteFilePathList = [];
|
|
||||||
for (i=0; i < note_extensions.length; i++) {
|
|
||||||
noteFilePathList.push(glob.sync(note_extensions[i]));
|
|
||||||
}
|
|
||||||
for (i=0; i < att_extensions.length; i++) {
|
|
||||||
attFilePathList.push(glob.sync(att_extensions[i]));
|
|
||||||
}
|
|
||||||
noteFilePathList = noteFilePathList.flat();
|
|
||||||
attFilePathList = attFilePathList.flat();
|
|
||||||
return [attFilePathList, noteFilePathList];
|
|
||||||
}
|
|
||||||
|
|
||||||
function find_unused_attachments(attachments, notes) {
|
|
||||||
for (i=0; i < attachments.length;i++) {
|
|
||||||
att = attachments[i];
|
|
||||||
for (j = 0; j < notes.length; j++) {
|
|
||||||
note = fs.readFileSync(notes[j], "utf-8");
|
|
||||||
att_referencedQ = note.includes(basename(att))
|
|
||||||
// TODO this probably doesn't work because I need to loop over each line
|
|
||||||
if (!att_referencedQ) {
|
|
||||||
print(basename(att))
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function basename(string) {
|
|
||||||
return string.split('\\').pop().split('/').pop(); // https://stackoverflow.com/a/25221100
|
|
||||||
}
|
|
||||||
|
|
||||||
function print(val) {
|
|
||||||
console.log(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
INSTALL_DIR="$HOME/.cadmus"
|
INSTALL_DIR="$HOME/.cadmus"
|
||||||
BIN_DIR="$HOME/.local/bin/"
|
BIN_DIR="$HOME/.local/bin/"
|
||||||
mkdir "${BIN_DIR}" > /dev/null
|
|
||||||
|
|
||||||
main () {
|
main () {
|
||||||
me=`basename "$0"`
|
me=`basename "$0"`
|
||||||
|
15
todo.org
15
todo.org
@ -41,21 +41,6 @@ should I restructure the subfunctions to accept only 1 argument either help or d
|
|||||||
+ Less Extensible
|
+ Less Extensible
|
||||||
* WAIT Switch back to MDCat
|
* WAIT Switch back to MDCat
|
||||||
When [[https://github.com/lunaryorn/mdcat/issues/155][this issue]] is resolved switch back to MDCat
|
When [[https://github.com/lunaryorn/mdcat/issues/155][this issue]] is resolved switch back to MDCat
|
||||||
* TODO Add Dokuwiki Export
|
|
||||||
|
|
||||||
just like ~html-dir~ add ~dw-dir~ using this script:
|
|
||||||
|
|
||||||
- =~/bin/ImportHtml2Dokuwiki.sh=
|
|
||||||
|
|
||||||
* TODO Fix Media Wiki Export
|
|
||||||
The links in the html-dir export are absolute, a second pass is needed to make them relative, this will be necessary for everything except for self-contained stuff.
|
|
||||||
|
|
||||||
Make a seperate function for self contained and relative stuff.
|
|
||||||
|
|
||||||
Currently html-dir CANNOT be used to import into mediawiki because even thtough the files get pulled in the links are broken.
|
|
||||||
|
|
||||||
calling ~pandoc ./file.html --extract-media='./media' -o ./file.html~ is necessary to import a zip file into mediawiki.
|
|
||||||
|
|
||||||
|
|
||||||
* HOLD [#A] NoteFind.sh
|
* HOLD [#A] NoteFind.sh
|
||||||
** KeyBindings
|
** KeyBindings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user