The template based note-taking tool Tp-Note was originally designed as desktop application: Before creating a new note, the user copies interesting bits of text into the clipboard. When Tp-Note starts, it analyses the clipboard's content and fills out some template to create a new note. This is why people who are working with non-graphical headless systems could not use Tp-Note efficiently: in general, these systems offer no clipboard. With version 1.7, Tp-Note comes with a new feature making it interesting for system administrators and console lovers: instead of injecting data into the templates via the clipboard, Tp-Note also reads the standard I/O input stream stdin. This way Tp-Note offers its full functionality on headless systems.

Tip: If you are new to Tp-Note, you may want to watch the introductory video about Tp-Note.


As Tp-Note makes extensive use of the clipboard, it mainly targets desktop systems running a graphical environment. But also when working on the console Tp-Note can be useful with its built-in clipboard simulation: Instead of copying the content into your clipboard, pipe it into Tp-Note

1
echo  "Some clipboard content" | tp-note

Typical workflows

The following examples work with the full featured version of Tp-Note as well as with the --no-default-features console-only version.

  • Document a downloaded file:

    Download the file i3-extensions.zip:

    wget "http://blog.getreu.net/_downloads/i3-extensions.zip"
    

    Document from where you downloaded the file:

    echo  "[download](<http://blog.getreu.net/_downloads/i3-extensions.zip>)" | tp-note i3-extensions.zip
    

    This creates the file i3-extensions.zip--URL.md with the following content:

    ---
    title:      "i3-extensions.zip"
    subtitle:   "URL"
    author:     "getreu"
    date:       "2020-09-03"
    lang:       "en-GB"
    ---
    
    [i3-extensions.zip](<i3-extensions.zip>)
    
    [download](<http://blog.getreu.net/_downloads/i3-extensions.zip>)
    
  • Download a webpage, convert it to Markdown and insert the result into a Tp-Note file. The note's title is the name of the first hyperlink found in the webpage.

    Install pandoc and curl:

    sudo apt install pandoc curl
    

    Download and convert:

    curl 'https://blog.getreu.net' | pandoc -f html -t markdown_strict | tp-note
    
  • Download a webpage while preserving its metadata:

    Same as above, but the following preserves the webpage's metadata, e.g. title, author, date... :

    curl 'https://blog.getreu.net' | pandoc --standalone -f html -t markdown_strict+yaml_metadata_block | tp-note
    

    creates the note file 20200910-Jens\ Getreu\'s\ blog.md with the webpage's content.

  • Generate a note for a given content with YAML header:

    echo -e "---\ntitle: Todo\nfile_ext: mdtxt\n---\n\nnothing" | tp-note
    

    creates the file 20200910-Todo.mdtxt with the content:

    ---
    title:      "Todo"
    subtitle:   ""
    author:     "getreu"
    date:       "2020-09-13"
    lang:       "en-GB"
    file_ext:   "mdtxt"
    ---
    
    nothing
    
  • Reformat the header of a note file:

    mv "20200921-My Note.md" "20200921-My Note-(1).md"
    cat "20200921-My Note-(1).md" | tp-note --batch
    

    creates the file 20200921-My Note.md with a rearranged header and the same body.

  • Launch, for once only, a different file editor.
    The external file editor, Tp-Note defaults to, is defined in the configuration file and can be changed there. If you want to use a different file editor just for one-shot, type:

    FILE=$(tp-note --batch); vi "$FILE"; tp-note --batch "$FILE"
    
  • Create a new note overwriting the template's default for subtitle:

    cd dev
    echo -e "---\nsubtitle: Draft\n---\n# Draft" | tp-note
    

    creates the note file 20200925-dev--Draft.md with the content:

    ---
    title:      "dev"
    subtitle:   "Draft"
    author:     "getreu"
    date:       "2020-09-25"
    lang:       "en-GB"
    ---
    
    # Draft
    
  • Synchronize filenames and headers of all note files in the current directory:

    find . -type f -name "*.md" -exec tp-note --batch {} \; >/dev/null
    
  • Generate an HTML rendition of an existing note file in the same directory:

    tp-note --export='./my_notes' './my_notes/20210209-debug--Note.md'
    

    or, equivalent but shorter:

    tp-note --export= './my_notes/20210209-debug--Note.md'
    

    or, even shorter:

    tp-note -x '' './my_notes/20210209-debug--Note.md'
    
  • Generate a PDF rendition of an existing note file :

    Install the wkhtmltopdf-tool:

    sudo apt install wkhtmltopdf
    

    Generate the PDF rendition of the existing note 20210122-my--Note.md:

    tp-note -x - '20210122-my--Note.md' | wkhtmltopdf - '20210209-debug--Note.md.pdf'
    
  • View and follow hyperlinks in a note file:

    When no graphical environment is available, Tp-Note disables the viewer feature with its internal HTTP server. However, in order to follow comfortably hyperlinks in you notes, you can always use Tp-Note's HTML export.

    Install the text-based web browser lynx:

    sudo apt install lynx
    

    Convert the existing note 20210122-my_note.md into HTML and open the rendition with lynx:

    tp-note -x - '20210122-my_note.md' | lynx --stdin
    

    The above also works in case Tp-Note was compiled with --no-default-features which is recommended for headless systems.

1

More examples can be found in Tp-Note's user manual.

Installation on headless systems

On headless systems, it is recommended to compile Tp-Note without its viewer and message-box features:

cargo install --no-default-features tp-note
sudo cp ~/.cargo/bin/tp-note /usr/local/bin

Configure the text-based file manager MidnightCommander

The Ncurses library based file manager MidnightCommander mc enjoys great popularity among people working on the console. The following configures mc's [F3]-key to open .md files for viewing. This is where Tp-Note generates the HTML rendition of the note file and opens the rendition with the Lynx web browser. The [Enter]-key runs Tp-Note in editing mode.

First install the Lynx web browser:

sudo apt install lynx

Edit mc's configuration file /etc/mc/mc.ext:

sudo nano /etc/mc/mc.ext

Replace the line default/* with:

shell/i/.md
    Open=tp-note %f
    View=if HTML=`tp-note -b -n -x - %f`; then (echo $HTML | lynx --stdin); else less %f; fi

default/*

Restart all instances of mc :

sudo killall mc
mc

To test the configuration, navigate to some .md note file and press [F3] or [Enter].

Read more

A good start is Tp-Note's project page or the introductory video. The source code is available on GitHub - getreu/tp-note and some binaries and packages for Linux, Windows and Mac can be found here. To fully profit of Tp-note, I recommend reading Tp-Note's user manual. When you like Tp-Note, you probably soon want to customize it. How to do so, is explained in Tp-Note's manual page.


Update 2021-02-16: add examples using recently implemented features