Created
January 15, 2020 17:45
-
-
Save dbridges/3b5820e86898e033ffc13ce2a105b9a2 to your computer and use it in GitHub Desktop.
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
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