|
|
@ -32,6 +32,7 @@ source "inc/tag-management" |
|
|
|
source "inc/file-management" |
|
|
|
source "inc/file-management" |
|
|
|
source "inc/yaml" |
|
|
|
source "inc/yaml" |
|
|
|
source "inc/fzf" |
|
|
|
source "inc/fzf" |
|
|
|
|
|
|
|
source "inc/to-html" |
|
|
|
|
|
|
|
|
|
|
|
# Utility functions |
|
|
|
# Utility functions |
|
|
|
# ################################################## |
|
|
|
# ################################################## |
|
|
@ -304,6 +305,26 @@ indexFolder(){ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
convert(){ |
|
|
|
|
|
|
|
local destination |
|
|
|
|
|
|
|
local method |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while [[ $1 = -?* ]]; do |
|
|
|
|
|
|
|
case "$1" in |
|
|
|
|
|
|
|
--to-html) method="to-html"; destination="html" ;; |
|
|
|
|
|
|
|
esac |
|
|
|
|
|
|
|
shift |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ -n "$1" ] && destination="$1" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ -z "$method" ] && die "You must specify a conversion method" |
|
|
|
|
|
|
|
[ -z "$destination" ] && die "You must specify a destination" |
|
|
|
|
|
|
|
[ -d "$destination" ] || die "$destination must be a directory" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"$method" "$destination" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainScript() { |
|
|
|
mainScript() { |
|
|
|
############## Begin Script Here ################### |
|
|
|
############## Begin Script Here ################### |
|
|
@ -319,6 +340,7 @@ mainScript() { |
|
|
|
|
|
|
|
|
|
|
|
case "${args[0]}" in |
|
|
|
case "${args[0]}" in |
|
|
|
add) addFile "${args[@]:1}"; safeExit ;; |
|
|
|
add) addFile "${args[@]:1}"; safeExit ;; |
|
|
|
|
|
|
|
convert) convert "${args[@]:1}"; safeExit ;; |
|
|
|
deepsearch) deepSearch "${args[@]:1}"; safeExit ;; |
|
|
|
deepsearch) deepSearch "${args[@]:1}"; safeExit ;; |
|
|
|
del|delete) deleteFile "${args[@]:1}"; safeExit ;; |
|
|
|
del|delete) deleteFile "${args[@]:1}"; safeExit ;; |
|
|
|
edit) editFile "${args[@]:1}"; safeExit ;; |
|
|
|
edit) editFile "${args[@]:1}"; safeExit ;; |
|
|
@ -354,41 +376,41 @@ usage() { |
|
|
|
This tool helps manage my personal knowledge base |
|
|
|
This tool helps manage my personal knowledge base |
|
|
|
|
|
|
|
|
|
|
|
Options: |
|
|
|
Options: |
|
|
|
-q, --quiet Quiet (no output) |
|
|
|
-q, --quiet Quiet (no output) |
|
|
|
-v, --verbose Output more information. (Items echoed to 'verbose') |
|
|
|
-v, --verbose Output more information. (Items echoed to 'verbose') |
|
|
|
-d, --debug Runs script in BASH debug mode (set -x) |
|
|
|
-d, --debug Runs script in BASH debug mode (set -x) |
|
|
|
-h, --help Display this help and exit |
|
|
|
-h, --help Display this help and exit |
|
|
|
--data <directory> The knowledgebase data dir |
|
|
|
--data <directory> The knowledgebase data dir |
|
|
|
--sqlite <file> The sqlite file (default to <data>/knowledgebase.sqlite3 |
|
|
|
--sqlite <file> The sqlite file (default to <data>/knowledgebase.sqlite3 |
|
|
|
--editor <editor> The editor to use (default $EDITOR or vim) |
|
|
|
--editor <editor> The editor to use (default $EDITOR or vim) |
|
|
|
--pager <editor> The pager to use (default bat or $PAGER or cat) |
|
|
|
--pager <editor> The pager to use (default bat or $PAGER or cat) |
|
|
|
--nogit Don't run git commands |
|
|
|
--nogit Don't run git commands |
|
|
|
--version Output version information and exit |
|
|
|
--version Output version information and exit |
|
|
|
|
|
|
|
|
|
|
|
Commands: |
|
|
|
Commands: |
|
|
|
init Initialise a new knowledgebase |
|
|
|
init Initialise a new knowledgebase |
|
|
|
new [options] [title] Create new entry |
|
|
|
new [options] [title] Create new entry |
|
|
|
--filetype <type> Type of file ( default md) |
|
|
|
--filetype <type> Type of file ( default md) |
|
|
|
edit [title] Edit a file |
|
|
|
edit [title] Edit a file |
|
|
|
list List all files |
|
|
|
list List all files |
|
|
|
--noheader Don't include the header |
|
|
|
--noheader Don't include the header |
|
|
|
--normal List items of type \"normal\" |
|
|
|
--normal List items of type \"normal\" |
|
|
|
list-tags Lists tags with the number of times its used |
|
|
|
list-tags Lists tags with the number of times its used |
|
|
|
--noheader Don't include the header |
|
|
|
--noheader Don't include the header |
|
|
|
purge-tags Deletes any unused tags |
|
|
|
purge-tags Deletes any unused tags |
|
|
|
update <file> [<file>] Updates the database and git repo of a changed file |
|
|
|
update <file> [<file>] Updates the database and git repo of a changed file |
|
|
|
If 2 files are given, it assumes a move |
|
|
|
If 2 files are given, it assumes a move |
|
|
|
view View a file |
|
|
|
view View a file |
|
|
|
add [options] <file> Adds a file |
|
|
|
add [options] <file> Adds a file |
|
|
|
--asset Adds the file as an asset |
|
|
|
--asset Adds the file as an asset |
|
|
|
--yaml-header Adds a yaml header (default for markdown files) |
|
|
|
--yaml-header Adds a yaml header (default for markdown files) |
|
|
|
--yaml-file Adds a yaml file (default for non-markdown files) |
|
|
|
--yaml-file Adds a yaml file (default for non-markdown files) |
|
|
|
fuzzy [command] Fuzzy select a file |
|
|
|
fuzzy [default] Fuzzy select a file |
|
|
|
command is what to do with the selected file |
|
|
|
git [options] Run arbitary git commands on the kb repository |
|
|
|
edit or view |
|
|
|
del [title] Delete a file |
|
|
|
git [options] Run arbitary git commands on the kb repository |
|
|
|
index Indexes the folder (usful after a clone etc) |
|
|
|
del [title] Delete a file |
|
|
|
convert [options] [dest] Converts the notes into a different format and puts it in dest |
|
|
|
index Indexes the folder (usful after a clone etc) |
|
|
|
--to-html Converts to html |
|
|
|
" |
|
|
|
" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|