Last active
April 1, 2018 05:57
-
-
Save rajivrnair/c1962061b1bda9236ce2be983545e32e to your computer and use it in GitHub Desktop.
simple journal with vi
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
# Create a folder and write a simple script to open a file. | |
$> mkdir /Journal && cd /Journal && touch writer.sh && chmod u+rwx writer.sh` | |
# Here's `writer.sh` | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
#!/bin/zsh | |
# create a folder with today's date if it does not exist | |
folder=`date +%Y_%m_%d` | |
mkdir -p $folder | |
cd $folder | |
# start vim in insert mode + create file for today's journal. | |
vi +star `date +%Y%m%d`".jrnl" | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Write an alias into your zshrc or bash_profile so you can get to it from anywhere. | |
alias journal="cd /Journal;./writer.sh" |
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
# Note: comments in .vimrc start with a " and not a # - this is just for easier markdown. | |
# Enable spell check and also toggle it. | |
set spell spelllang=en_gb | |
cmap <F6> setlocal spell! | |
# Setup a simple statusline - the focus is on less clutter and just the info I need. | |
function! WordCount() | |
let s:old_status = v:statusmsg | |
let position = getpos(".") | |
exe ":silent normal g\<c-g>" | |
let stat = v:statusmsg | |
let s:word_count = 0 | |
if stat != '--No lines in buffer--' | |
let s:word_count = str2nr(split(v:statusmsg)[11]) | |
let v:statusmsg = s:old_status | |
end | |
call setpos('.', position) | |
return s:word_count | |
endfunction | |
hi User1 ctermbg=black ctermfg=red cterm=BOLD guibg=black guifg=red gui=BOLD | |
set laststatus=2 | |
set statusline= | |
set statusline+=%1* # use the highlight specified above. | |
set statusline+=%<\ # cut at start | |
set statusline+=%-40t\ # path | |
set statusline+=%= # left/right separator | |
set statusline+=%10([%l,%c]%)\ # line and column | |
set statusline+=(wc:%{WordCount()}) # word count | |
# Some journalling options | |
# Every time you open a journal file (create/edit), append the timestamp | |
autocmd VimEnter *.jrnl $pu=strftime('%n[%a, %d %b %Y %T %z]%n%n') | |
# Set line number | |
autocmd VimEnter *.jrnl setl number | |
# Indicate column 120 - just to get a visual indication of an end margin. | |
autocmd VimEnter *.jrnl set colorcolumn=120 | |
# Indicate the current line. | |
autocmd VimEnter *.jrnl set cursorline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment