Skip to content
Alfonso Montero edited this page Oct 4, 2021 · 10 revisions

Display markdown notes formatted in terminal

  1. install mdv
  2. make a wrapper /usr/local/sbin/mdless
    #!/bin/zsh
    # https://superuser.com/questions/1059781/what-exactly-is-in-bash-and-in-zsh
    /usr/bin/less -R -c =(mdv "$1")
    # /usr/bin/less -R -c =(mdv -A "$1") # light background (not yet supported)
  3. set it in ~/.snclirc
    cfg_pager = /usr/local/sbin/mdless
    

(Thanks to @s5unty)

Alternatively, you might also consider using bat.

Use vim modeline in notes to auto-set filetype

I personally store a lot of my notes in Votl/VimOutliner format. Specific to Vim, I put a modeline at the end of these notes (note that Emacs also supports modelines):

; vim:ft=votl

Now when I edit this note Vim will automatically load the votl plugin. Lots of possibilities here...

(Thanks to @insanum)

Open links quickly

  • install urlview or urlscan
  • pipe the note to urlview/urlscan: |urlview
  • select and open a link!

Docker usage tips

The Docker installation option offers some flexibility in that you don't need to install dependencies outside of Docker itself to run. However, because sncli has both an interactive component as well as being scriptable by passing data via stdin there can be some subtle differences in the Docker command used in some situations. In general, -it needs to be passed to the Docker command when trying to use sncli interactively (this gives a full TTY allowing interaction) but only -i when trying to pass input. For example:

If you are trying to launch the GUI console, you might run exactly what's in the setup instructions:

docker run --rm -it -v /tmp:/tmp -v "$HOME/.sncli/:/root/.sncli/" -v "$HOME/.snclirc:/root/.snclirc" sncli

In order to create a new note from stdin, you'll need to drop the -t from the command, but still preserve the -i input argument:

echo "hello world" | docker run --rm -i -v /tmp:/tmp -v "$HOME/.sncli/:/root/.sncli/" -v "$HOME/.snclirc:/root/.snclirc" sncli create -

The above command can be simplified by using an alias in your shell:

alias sncli='docker run --rm -i -v /tmp:/tmp -v "$HOME/.sncli/:/root/.sncli/" -v "$HOME/.snclirc:/root/.snclirc" sncli'

Then you can interact with sncli as though Docker wasn't there (aside from the interactive nuance from above):

echo "hello world" | sncli create -

Also, you can skip completely the .snclirc file under Docker by passing SN_USERNAME and SN_PASSWORD environment variables (-e switch). Use sncli --config=/dev/null command line option to suppress the error message.

You might also want to pass the TERM, LINES, COLUMNS, LANG, TZ environment variables from your host environment to the container depending on your system.

View trash

Run a g-style search for tag:trash to view all trashed notes.

Currently there isn't a method to empty the trash or permanently delete notes; see tracking issue insanum/sncli#111