Skip to content

Instantly share code, notes, and snippets.

@dbridges
Created January 15, 2020 17:45
Show Gist options
  • Save dbridges/3b5820e86898e033ffc13ce2a105b9a2 to your computer and use it in GitHub Desktop.
Save dbridges/3b5820e86898e033ffc13ce2a105b9a2 to your computer and use it in GitHub Desktop.
let g:notefile_base_path="~/Dropbox/notes"
function! CurrentNoteDir()
return fnamemodify(CurrentNotePath(), ":p:h")
endfunction
function! CurrentNotePath()
return substitute(getcwd(), $HOME, expand(g:notefile_base_path), "") . ".md"
endfunction
function! NotesInitNew()
call mkdir(CurrentNoteDir(), "p")
if !filereadable(CurrentNotePath())
let l:title = "# " . fnamemodify(getcwd(), ":t")
call writefile([l:title], CurrentNotePath())
endif
silent call system("ln -s " . CurrentNotePath() . " .notefile")
endfunction
function! Notes()
if !filereadable(".notefile")
call NotesInitNew()
endif
execute "edit .notefile"
endfunction
command! Notes call Notes()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment