-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.sh
More file actions
executable file
·71 lines (60 loc) · 2.5 KB
/
Copy pathnotes.sh
File metadata and controls
executable file
·71 lines (60 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
#############################################################################
# Author: Guillaume Bouvier -- guillaume.bouvier@pasteur.fr #
# https://research.pasteur.fr/en/member/guillaume-bouvier/ #
# Copyright (c) 2025 Institut Pasteur #
#############################################################################
#
# creation_date: Tue Sep 30 10:23:09 2025
set -e # exit on error
set -o pipefail # exit when a process in the pipe fails
# set -o noclobber # prevent overwriting redirection
# Full path to the directory of the current script
DIRSCRIPT="$(dirname "$(readlink -f "$0")")"
# MYTMP=$(mktemp -d) # Temporary directory for the current script. Use it to put temporary files.
# trap 'rm -rvf "$MYTMP"' EXIT INT # Will be removed at the end of the script
function usage () {
cat << EOF
Open the NOTES.md file as an html file in google-chrome.
Options:
-h, --help Print this help message and exit.
-d, --display Open the NOTES.md file as an html file in google-chrome.
-e, --edit Open the NOTES.md file in vim to edit.
-a, --aider Open the NOTES.md file in aider to edit.
-c, --commit Commit the NOTES.md file using aider.
EOF
}
function display () {
pandoc -s -f markdown -t html --css $DIRSCRIPT/notes.css $DIRSCRIPT/NOTES.md > $DIRSCRIPT/notes.html
google-chrome $DIRSCRIPT/notes.html
}
function edit () {
vim -c 'set mouse=' -c 'set spell' -c 'set spelllang=en_us' \
-c 'highlight SpellBad term=underline cterm=underline ctermbg=NONE gui=underline guibg=NONE' \
-c 'highlight SpellCap term=underline cterm=underline ctermbg=NONE gui=underline guibg=NONE' \
-c 'highlight SpellRare term=underline cterm=underline ctermbg=NONE gui=underline guibg=NONE' \
-c 'highlight SpellLocal term=underline cterm=underline ctermbg=NONE gui=underline guibg=NONE' \
$DIRSCRIPT/NOTES.md
}
function aider_edit () {
display
aider $DIRSCRIPT/NOTES.md
display
}
function aider_commit () {
aider --commit $DIRSCRIPT/NOTES.md
}
# N=1 # Default value
while [ "$#" -gt 0 ]; do
case $1 in
# -n|--number) N="$2"; shift ;;
-h|--help) usage; exit 0 ;;
-d|--display) display; exit 0 ;;
-e|--edit) edit; exit 0 ;;
-a|--aider) aider_edit; exit 0 ;;
-c|--commit) aider_commit; exit 0 ;;
--) OTHER="${@:2}";break; shift;; # Everything after the '--' symbol
*) usage; exit 1 ;;
esac
shift
done