-
-
Save mrnugget/747d58e29caf9c1726ad to your computer and use it in GitHub Desktop.
n -- my note taking tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| # Requirements: | |
| # fzz - github.com/mrnugget/fzz | |
| # selecta - github.com/garybernhardt/selecta | |
| # the_silver_searcher/ag - github.com/ggreer/the_silver_searcher | |
| # Usage: | |
| # n [name] - Create note | |
| # n l - List all the notes and use selecta to fuzzy-search | |
| # for a note, open the selected note with $EDITOR | |
| # n fzz - Use fzz and ag to search through notes, open the matched | |
| # files with $EDITOR | |
| export EDITOR='/Applications/MacVim.app/Contents/MacOS/Vim' | |
| npath=${NOTES_PATH:-"${HOME}/Dropbox/notes"} | |
| date_format="%Y-%m-%d" | |
| if [ ! -d "${npath}" ]; then | |
| mkdir -p "${npath}" | |
| fi | |
| command=$1 | |
| case $command in | |
| l) | |
| exec $EDITOR $(find ${npath}|selecta) | |
| ;; | |
| fzz) | |
| exec $EDITOR $(fzz ag {{}} ${npath} | awk -F":" '{print $1}' | uniq) | |
| ;; | |
| *) | |
| file_name="${npath}/$(date +${date_format})-$(echo $* | tr ' ' '_').md" | |
| exec $EDITOR ${file_name} | |
| ;; | |
| e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment