Shell Scripts for Managing Markdown Notes

栏目: IT技术 · 发布时间: 5年前

内容简介:Shell Scripts to Facilitate Effective Note TakingThis is aIt's command based and prints out available subcommands for any given command, these means you can use a directory of markdown files like a personal wiki, much like OneNote/Evernote/Notable, for exa

cadmus

Shell Scripts to Facilitate Effective Note Taking

Introduction

This is a self-contained shell script that uses pre-existing tools (such as TMSU and recoll) to provide an interface for markdown notes.

It's command based and prints out available subcommands for any given command, these means you can use a directory of markdown files like a personal wiki, much like OneNote/Evernote/Notable, for example:

Shell Scripts for Managing Markdown Notes

and an overview of what it looks like in the terminal

Shell Scripts for Managing Markdown Notes

For example if you wanted to extract all the tags from your markdown notes (either #tags or from the YAML), cadmus has a tool for that:

Shell Scripts for Managing Markdown Notes

Ultimately the idea is it is to act a menu to dispatch different scripts I already had so I could more easily share those scripts with classmates.

The real heavy lifting is done by Pandoc, Recoll, ripgrep, skim/fzf, TMSU etc.

Installation

Automatic

Copy this into your shell:

cd $(mktemp -d)
wget https://raw.githubusercontent.com/RyanGreenup/cadmus/master/install.sh
bash install.sh
  • Cadmus will work from within a self-contained directory and add a symlink to ~/.local/bin
    • in this way it's zero lock-in, it does not modify your curr directory of Markdown files.
  • Installation will automatically create a config file in its directory (which is by default ~/.cadmus
  • The script will list anythat are not satisfied.

Manual

To install manually:

  1. Download cadmus and put it into the PATH
    git clone https://github.com/RyanGreenup/cadmus ~/.cadmus  \
    || echo "Delete $HOME/.cadmus first"
    mkdir -p $HOME/.local/bin
    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
When first run, the script will prompt you to make a config file in the directory in which it is run.

Assumptions

It is assumed that:

  1. Notes are:
    1. Markdown files with a .md extension
    2. Recoll updates it's index on the fly
      • The notes directory will need to be indexed by Recoll in order for the results to show up when using cadmus search .
  2. SSD
    • I use an SSD and so I let some scripts be pretty inefficient (for example something like grep | cut | xargs find to avoid creating a variable), I don't know if HDD performance would be great.
  3. All Notes have Unique Names
  4. On MacOS you'll need to define xdg-open and have GNU coreutils, so do something like:
alias xdg-open='open &>/dev/null' 
alias realpath=grealpath &>/dev/null

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 .

Design Philosophy

  • cadmus acts as a menu for scripts to acheive things
    • 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
    • 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, Free as in Speech and Beer.
  • try to make modular subscripts:
    • Pipe in input, output goes to STDOUT

Dependencies

Recommended for all Features

Interesting / Helpful / Recommended Generally (Not strictly necessary)

PATH

If any dependencies are 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

Recommended Aliases

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

Why / Comparison with other tools

So the boxes I needed ticked are, more or less:

FOSS Offline Linux/BSD? terminal? RawFiles? Markdown AnyEditor?
OneNote :x: :x: :x: :x: :x: :x: :x:
EverNote :x: ? :x: :x: :x: :x: :x:
Notable :x: :white_check_mark: :white_check_mark: :x: :white_check_mark: :white_check_mark: :white_check_mark:
Zim :white_check_mark: :white_check_mark: :white_check_mark: :x: :white_check_mark: :white_check_mark: :white_check_mark:
Obsidian :x: :white_check_mark: :white_check_mark: :x: :white_check_mark: :white_check_mark: :white_check_mark:
dokuwiki :white_check_mark: :x: :white_check_mark: :x: :white_check_mark: :white_check_mark: * :white_check_mark:
joplin :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :x: :white_check_mark: :x:
mediawiki :white_check_mark: :x: :white_check_mark: :x: :x: :x: :x:
Org-Mode :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :x: :x:
Cadmus :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
† You can't open the files from vim with FZF so it gets a no.   ‡ Unlike dokuwiki everything is in a database so it gets a no   * With a Plugin  

Related


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

从莎草纸到互联网:社交媒体2000年

从莎草纸到互联网:社交媒体2000年

[英]汤姆·斯丹迪奇 / 林华 / 中信出版社 / 2015-12 / 58.00元

【内容简介】 社交媒体其实并不是什么新鲜的东西。从西塞罗和其他古罗马政治家用来交换信息的莎草纸信,到宗教改革、美国革命、法国大革命期间印制的宣传小册子,过去人类跟同伴交流信息的方式依然影响着现代社会。在报纸、广播和电视在散播信息上面统治了几十年后,互联网的出现使社交媒体重新变成人们与朋友分享信息的有力工具,并推动公共讨论走向一个新的模式。 汤姆•斯丹迪奇在书中提醒我们历史上的社交网络其......一起来看看 《从莎草纸到互联网:社交媒体2000年》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码