markdown notes from terminal (airbornelamb/cli-notes)
This file contains 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
# to be added to .bashrc | |
# have edited nl and ns func to show preview in bat | |
# add markdown extension by default | |
nn() | |
{ | |
local note_name="$*" | |
local note_date="`date +%F`" | |
local note_ext="md" | |
if [[ $note_name == "" ]]; then | |
note_name="$note_date.$note_ext" | |
else | |
note_name="$note_name.$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 'batcat --theme TwoDark --color "always" {}')" | |
if [[ -n $file ]]; then | |
vim $file | |
fi | |
} | |
nl() | |
{ | |
local files | |
files="$(rg --files $NOTESDIR | fzf --preview 'batcat --theme TwoDark --color "always" {}')" | |
if [[ -n $files ]]; then | |
vim $files | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment