In this short post I will tell you how you can become more efficient at writing by automating boring tasks.

As you could see, some time ago I started posting protips with one goal in mind: the whole process should not take more than 15 minutes. After a few weeks I can even finish a protip in less than 10 minutes.

Limited resources like:

  • Time,
  • Money,
  • Assets,
  • People or
  • Space

Makes you creative and forces you to use what you have right now. In my case I use many tools and techniques to focus on what’s really important: writing useful protips. I won’t lie to you. Honing tools and techniques took many hours, but I’ve learnt a lot on the way. Curious? Read on!

Slow process

15 minutes and the time begin to pass. What should I write about? 30 seconds have already passed and you’re stuck. Perhaps I should keep a list of small things I’ve learnt today?

You’re opening iTerm and fire vim. You also need to start jekyll and a browser window in order to see changes. Time passes. You create a new file and throw some jekyll Front Matter. Tick, tick, tick. The page has to be saved and the url has to be SEO-friendly. Done.

Commit, push. Open Twitter and let the world know. Tick, tick, tick. 30 minutes, not 15. Can you see the pattern? If not, you will definitely see after having to go through all the steps each single day. Now compare it with this.

Automated process on steroids

Tmux and Tmuxinator

# ~/.tmuxinator/blog.yml
windows:
  - editor:
      layout: main-vertical
      panes:
        - nvim _protips
        - nvim til.md
        - gf origin master
  - jekyll: jekyll serve
➜  tmuxinator start blog

Setup distractless environment

function! SetupWriting()
    setlocal spell spelllang=en
    setlocal wrap linebreak nolist
    setlocal textwidth=0 wrapmargin=0
    setlocal formatoptions-=t
    set formatprg=par\ -w90

    call pencil#init({'wrap': 'soft'})

    call textobj#quote#init()
    map <silent> <leader>qc <Plug>ReplaceWithCurly
    map <silent> <leader>qs <Plug>ReplaceWithStraight
    map <leader>g :Goyo<CR>:GitGutterEnable<CR>

    au FileType markdown nmap <leader>fr :call Formd("-r")<CR>
    au FileType markdown nmap <leader>fi :call Formd("-i")<CR>
    au FileType markdown nmap <leader>ft :call Formd("-f")<CR>
endfunction
function! SetupProtip()
    " start measuring time
    :setlocal spell spelllang=en
    :let l:protipTemplatePath = '~/projects/blog/protip-template.md'
    :let l:newProtipPath      = '~/projects/blog/_drafts/' . strftime("%Y-%m-%d") . "-protip.md"
    :exe 'edit ' . l:newProtipPath
    :exe 'read ' . l:protipTemplatePath
    :call SetupWriting()
    :Goyo
    :!open http://localhost:4000
endfunction
:call SetupProtip()

Writing

Before:

---
layout: post
title: new_title
tags:
  - protip
---

First para

After:

---
layout: post
title: new_title
tags:
  - protip
  - vim
---

Vim is awesome

Blast off!

At this point I’m copying title Vim is awesome to register t. See what’s happening after.

function! MakeProtipUrl()
    :let l:protipUrl = tolower(@t)
    :let l:protipUrl = substitute(l:protipUrl, "[\*\`\.\?\:]*", '', 'g')
    :let l:protipUrl = substitute(l:protipUrl, "[~ ]", '-', 'g')
    :let l:protipUrl = strftime("%Y-%m-%d") . "-" . l:protipUrl . '.md'

    :let l:protipBlogUrl = substitute(l:protipUrl, "\.md", "", '')
    :let l:protipBlogUrl = "http://ryrych.pl/protips/" . l:protipBlogUrl

    :let @u = l:protipUrl
    :let @h = l:protipBlogUrl
endfunction
:call MakeProtipUrl()

Now I have the following data:

  • 2016-05-12-vim-is-awesome.md in register u
  • http://ryrych.pl/protips/2016-05-12-vim-is-awesome in register h

Going wild!

function! PublishProtip()
    :3s/new_title/\=@t
    :Gw
    :echo system("git ci ". '-m ' . string(@t))
    :!git push origin master
    :PosttoTwitter
    " stop measuing time
endfunction

:PosttoTwitter awaits input: title (register t) and url register h.

It’s possible!

I’m going to streamline the process even further. I believe that it’s possible to share something useful in 8 minutes. What about you? Are you going to joing the challenge?