Git Product home page Git Product logo

cli-notes's Introduction

What is this project?

I got tired of paying for Evernote and searched endlessly for a note system that was flexible and extremely fast. I wanted it all: plaintext markdown notes in simple folders with fulltext search. Yet everything out there seemed to compromise in one of these areas.

Getting Started

This project contains only two simple things which are contained in this readme:

  1. An append to vimrc that will install FZF and ripgrep for you
  2. A shell alias and functions to wrap those tools into something usable for notes

Installing

You must first install ripgrep and fzf. Below is the easiest way to do that.

  1. Paste this section at the top of your vimrc, which will cause vim to install ripgrep
""" Auto Installation credit to https://github.com/bag-man/dotfiles
if !empty(glob("~/.fzf/bin/fzf"))
    if empty(glob("~/.fzf/bin/rg"))
      silent !curl -fLo /tmp/rg.tar.gz
            \ https://github.com/BurntSushi/ripgrep/releases/download/0.7.1/ripgrep-0.7.1-x86_64-unknown-linux-musl.tar.gz
      silent !tar xzvf /tmp/rg.tar.gz --directory /tmp
      silent !cp /tmp/ripgrep-0.7.1-x86_64-unknown-linux-musl/rg ~/.fzf/bin/rg
    endif
endif
  1. Now paste this into your plugin section to install fzf. Change the beginning to reflect which plugin system you are using (vundle etc). I am using Plug by the same author as fzf, JuneGunn.
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  1. Run your plugin updater, for example vim :PlugUpdate for Plug

  2. Lastly, copy the following into your shell rc file (.zshrc, .bashrc etc...). I have the NOTESDIR as the default for Syncthing, which is awesome.

export NOTESDIR="$HOME/Sync/notes"

nn() {
  local note_name="$*"
  local note_date="`date +%F`"
  local note_ext="md"  
  if [[ $note_name == "" ]]
  then
    note_name="$note_date.$note_ext"
  fi
  mkdir -p $NOTESDIR
  vim -c 'startinsert' "$NOTESDIR/$note_name"
}

ns() {
  local file
  [ -z "$1" ] && echo "No argument supplied - Enter a term to search" && return 1
  file="$(rg --files-with-matches --no-ignore --ignore-case --hidden --no-heading --no-messages $1 $NOTESDIR | fzf --preview "head -100 {}")"
  if [[ -n $file ]]
  then
    vim $file
  fi
}

nl() {
  local files
  files="$(rg --files $NOTESDIR | fzf --preview "head -100 {}")"
  if [[ -n $files ]]; then
    vim $files
  fi
}

Usage

Congratulations! You now have three functions

  • Typing nn (short for New Note) will trigger vim to open straight into insert mode ready to type a note with today's date as the filename.
  • Typing nn FILENAME will do the same thing but with the filename you specify.
  • Typing ns TERM (short for Note Search) will ripgrep inside your text files for a search term, then you will visually see the results and choose to open one in vim.
  • Typing nl (short for Note List) will bring up a visual list of all your notes for you to open one in vim

cli-notes's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.