mirror of
https://github.com/RyanGreenup/cadmus.git
synced 2025-09-02 18:33:08 +02:00
Merge branch 'master' of https://github.com/RyanGreenup/cadmus
This commit is contained in:
@@ -4,3 +4,12 @@
|
|||||||
+ ~bat~ works with ~.org~ without needing to use org-ruby or pandoc
|
+ ~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?)
|
+ Still having issues with ~mdcat~ not displaying results ocasionally (is this an issue with footnotes?)
|
||||||
- Added Rofi Menu
|
- 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
|
||||||
|
@@ -99,7 +99,7 @@ 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 "
|
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 "
|
||||||
@@ -357,7 +357,7 @@ 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)" ${@:-} && exit 0
|
backlinks) shift; "${script_dir}/tools/List-Backlinks.sh" "$(CLIP_OUT)" "${NOTES_DIR}" ${@:-} && 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
|
||||||
;;
|
;;
|
||||||
|
119
bin/rofi_find.sh
119
bin/rofi_find.sh
@@ -59,21 +59,21 @@ 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
|
||||||
echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
# echo -e " \e[3m\e[1m• Key Bindings\e[0m "
|
||||||
echo
|
# echo
|
||||||
echo
|
# echo
|
||||||
echo -e " \e[1;91m \e[1m Binding \e[0m\e[0m \e[1;34m┊┊┊ \e[0m Description "
|
# 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;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;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 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;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 - 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 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 -e " \e[1;94m Ctrl - o \e[0m \e[1;34m ┊┊┊ \e[0m \e[1m Open \e[0m in Default Program"
|
||||||
echo
|
# echo
|
||||||
|
|
||||||
echo -e " \e[3m\e[1m• Compatability \e[0m "
|
# echo -e " \e[3m\e[1m• Compatability \e[0m "
|
||||||
echo
|
# echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -86,6 +86,7 @@ readFirstArgument () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
# *** Skim and Grep, the important stuff
|
# *** Skim and Grep, the important stuff
|
||||||
|
#
|
||||||
rofi_over_Notes () {
|
rofi_over_Notes () {
|
||||||
|
|
||||||
## Change directory if One was specified, exit if no directory exists
|
## Change directory if One was specified, exit if no directory exists
|
||||||
@@ -106,7 +107,95 @@ rofi_over_Notes () {
|
|||||||
# **** Skim with Grep
|
# **** Skim with Grep
|
||||||
RofiFind () {
|
RofiFind () {
|
||||||
|
|
||||||
echo "mynote.md"
|
## 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
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
73
bin/tags/org_tags.py
Normal file
73
bin/tags/org_tags.py
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
#!/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
|
@@ -9,8 +9,9 @@ command -v xclip >/dev/null 2>&1 || { echo >&2 "I require xclip but it's not ins
|
|||||||
term=$(basename "${1}" | cut -f 1 -d '.')
|
term=$(basename "${1}" | cut -f 1 -d '.')
|
||||||
|
|
||||||
rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
|
rg -e "\[.*\]\(.*$term\.md\)" -e "\[\[$term\]\]" -e "\[\[$term.*\]\]" \
|
||||||
~/Notes/MD/notes \
|
"${NOTES_DIR}" \
|
||||||
-t markdown -ol
|
-t markdown -ol
|
||||||
|
# ~/Notes/MD/notes \
|
||||||
|
|
||||||
|
|
||||||
## If you want to preview the Backlinks
|
## If you want to preview the Backlinks
|
||||||
|
Reference in New Issue
Block a user