Objective
Since I've drifted away from Evernote, all of my notetaking has been stored locally in markdown. In this project I'm going to create a local directory and sync it up with a remote machine in my house using git to back my notebook up.
I also just discovered vimwiki via Hacker News and am really loving it. I'm still going to write all of my notes in markdown, but I'll also add vimwiki to the mix to help traverse my notebook.
Setup
You'll need all of these things to get started:
- Git installed locally.
- A dedicated home PC with SSH enabled for your remote machine (git should be installed here as well). I had an old netbook lying around (remember those?) and so I installed Lubuntu as my remote OS.
- A NoIP account.
- Access to your home router.
- Vimwiki (we'll get to how to install this later in the guide).
Setup NoIP on your remote machine
NoIP is a free service that allows you to get around that pesky issue of having a dynamic IP address from your ISP. If you have a static IP then you can skip all of the NoIP stuff and just skip to setting up your router.
- Create an account and domain at NoIP
- Install the NoIP client on your remote machine Client Download
Setup your router
- Login to your router and set your remote machine to a static IP so it doesn't change addresses every time it or the router is restarted.
- Also forward port 22 (SSH port) to your remote machine's IP.
Getting started with a simple git repo
Let's first create a new directory called notebook
on your home directory. Create an empty note file that we can use as an example and initialize a git repo:
mkdir ~/notebook
cd ~/notebook
touch first_note.md
git init
git add first_note.md
git commit -m 'first commit'
Create a bare directory on the remote machine
ssh <remote_machine>
git init --bare notebook.git
Connect your local repo to the remote git server
cd ~/notebook
git remote add origin <remote>:~/notebook.git
git push -u origin master
At this point you should have pushed your first commit up to your remote machine. Congrats! But we're not done yet...
Setup vimwiki for awesome notetaking
To setup vimwiki you'll need to make sure you have Pathogen installed first. This is a pretty easy install actually, I'll transcribe the steps here:
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
You can now setup all sorts of vim plugins through a very easy package manager designed for Vim! OK, now install vimwiki:
cd ~/.vim/bundle
git clone https://github.com/vimwiki/vimwiki.git
Vimwiki is now installed! However, there is some additional configuration to get all of vimwiki's features to work properly.
Add the following to ~/.vimrc
:
call pathogen#infect()
call pathogen#helptags()
set nocompatible
filetype plugin on
syntax on
let g:vimwiki_list = [{'path': '~/notebook/'}]
let g:vimwiki_list = [{'path': '~/notebook/', 'syntax': 'markdown', 'ext': '.md'}]
Vimwiki is now setup to default to the ~/notebook
directory and will use markdown files instead of the vimwiki default type.
Create your first notes
Now that you have vimwiki installed, open vim
to get started.
- Type
<Leader>ww
to createindex.md
.<Leader>
is typically set to\
.- You can change default key for
<Leader>
by adding this line to~/.vimrc
:let mapleader = ","
- Add
first_note
to the index. - Hover your cursor over
first_note
and press Enter. - You should now be on
~/notebook/first_note.md
which you created earlier! - Press Backspace to return to the index.
Sync your notes!
Finally, you'll want to sync everything. This should be pretty easy if you know git well, but the most basic steps would be:
git -C ~/notebook add -A
git -C ~/notebook commit -m "updated"
git -C ~/notebook push
If you haven't used git
much I recommend studying up on what the above commands actually do. You can even add a custom command to your bash instance. Add this to your .bashrc
or .zshrc
file:
alias syncnotes='git -C ~/notebook add -A && git -C ~/notebook commit -m "updated" && git -C ~/notebook push'
Now you can sync your notes simply by entering syncnotes
!
That's it! There are more options in vimwiki you can use, but I'll leave that discovery up to you. Happy notetaking!
Just another personal tech blog.
Python, Photography, Drawing and Games
QA Engineer from Portland, OR