1
0
mirror of https://github.com/RyanGreenup/cadmus.git synced 2025-02-06 06:08:30 +01:00
2020-07-20 05:10:02 +10:00
2020-07-20 00:15:53 +10:00
2020-07-13 01:29:53 +10:00
2020-07-14 21:39:40 +10:00
2020-07-13 01:29:53 +10:00
2020-07-14 23:12:56 +10:00
2020-07-13 01:29:53 +10:00
2020-07-12 22:16:24 +10:00
2020-07-14 01:41:31 +10:00
2020-07-14 01:41:31 +10:00
2020-07-20 05:10:02 +10:00
2020-07-17 00:14:49 +10:00
2020-07-16 21:16:20 +10:00
2020-07-14 00:06:27 +10:00

cadmus

Shell Scripts to Facilitate Effective Note Taking

Introduction

Essentially I used to have a dozen shell scripts in ~/bin that I use to capture notes, this is an attempt to wrap them into a single script and then have aliases to make them quick to access.

The idea is that it is just a menu to dispatch different scripts so I could share those scripts with classmates.

Design Philosophy

  • cadmus acts as a menu for scripts to acheive things
    • the script name will should always be printed to the terminal so the individual script can be repurposed with out fishing through code.
  • Subscripts will should take only one argument (or STDIN)
    • If the first argument is either -h or --help help will be printed and then exit 0
    • This might lead to some limitations but the simplicity is for sanity, modularity and extensibility.
    • Will always return absolute path.
      • I played around with relative path but it got confusing when calling the script from inside a function inside a script, so instead if you want a relative path you should do scriptname './' | xargs realpath --relative-to='./'
  • Be a Front end to tie together different scripts and tools
  • Don't replicate work other people have done.
  • Plain Text, Open Source.
  • Be Modular
    • Pipe in input, output goes to STDOUT
    • Leave Aliases and piping to the user
  • cadmus will take the notes directory from the global variable CADMUS_NOTES_DIR
    • 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 Arguments will be shifted and then all passed down to subfunctions

Installation

To install:

  1. satisfy the dependencies

  2. Set up Recoll

  3. Download cadmus and put it in the PATH

    git clone https://github.com/RyanGreenup/cadmus ~/.cadmus  \
    || echo "Delete $HOME/.cadmus first"
    ln -s "$HOME/.cadmus/bin/cadmus" "$HOME/.local/bin/"
    
    1. According to the SystemD Standard ~/.local/bin should be in $PATH, if you are using some other init implementation you can add this directory to "$PATH" it by doing something like this:

      ## Should work in bash/zsh/fish
      echo $PATH | grep "$HOME/.local/bin" &> /dev/null && echo "$HOME/.local/bin in path already" || ls "$HOME/.local/bin" &> /dev/null && echo 'PATH="$PATH:$HOME/.local/bin"' >> $HOME/.profile
      
      
  4. You will probably need to change the directory to your notes in the script:

    which cadmus | xargs xdg-open
    
    readonly NOTES_DIR="$HOME/Notes/"
    readonly SERVER_DIR="/var/www/html/MD"
    readonly MKDOCS_YML="$HOME/Notes/mkdocs.yml" 
    

-->

Configuring recoll

Currently the search just uses the default recoll config, I intend to modify this to use ~/.cadmus as a config directory so as to not interfere with the default config.

It isn't in practice an issue if ~/.recoll is indexing more than the notes because you can just modify the call to Skim (sk) in ..cadmus.. to start the call with ~/Notes/MD.

Usage

It's all Menu driven so just follow the diagram to do what you need.

Mindmap of Program Flow

Assumptions

It is assumed that:

  1. Notes are:
    1. Markdown files with a .md extension
    2. Underneath ~/Notes (you ma)
    3. Recoll updates it's index on the fly
      • ~/Notes will need to be indexed by Recoll so the results will show up.
  2. SSD
    • I use an SSD and some scripts are pretty inefficient (like grep | cut | xargs find to avoid creating a variable), I don't know if things like would work on a HDD.
  3. All Notes have Unique Names
  4. On MacOS you'll need to define xdg-open so do something like:
alias xdg-open='open &>/dev/null' 

Dependencies

PATH

If installed with pip or cargo it will be necessary to add these directories to your PATH:

## bash
echo '
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
' >> ~/.bashrc

## zsh
echo '
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
' >> ~/.bashrc

## fish

echo '
set PATH $HOME/.local/bin $PATH
set PATH $HOME/bin $PATH
set PATH "$HOME/.cargo/bin $PATH
' >> ~/.config/fish/config.fish

I wrote all this with aliases in mind, when I settle on some aliases i'll put up my fish functions. (I also wanted to do some autocomplete.)

Description
No description provided
Readme 29 MiB
Languages
CSS 64.7%
HTML 24.5%
Shell 7%
JavaScript 3%
R 0.7%
Other 0.1%