This is a neat little alias I’ve used before for taking notes with git:
export NOTES="$HOME/files/notes" # or whatever.
alias ngit="/usr/bin/git --git-dir=$NOTES/.git --work-tree=$NOTES"
Now ngit acts like git except relative to $HOME/files/notes, wherever you are. There’s
also a bonus alias if you use a text editor you can call from the terminal:
alias note="$EDITOR $NOTES/new"
So long as you “Save As” you’ll be good, otherwise you’ll have a file called new which
will be opened every time you call note. I also extended this for Vim-like editors:
alias note="$EDITOR \"+cd $NOTES\" \"+star\""
Lots of quote escaping makes this hard to read – here’s a rundown:
+cd $NOTESruns when vim opens, setting the working directory to$NOTES. This means if you save a file asfoo.md, it’ll get saved to$NOTES/foo.md.+starjumps into insert mode immediately.
This notes solution is fine, but it’s really a jumping-off point for building little aliases which enrich the way you use the terminal, and help build a deeper understanding for how shell scripting works.
...Maybe I should make an alias blog-post 🤔