Skip to content

Instantly share code, notes, and snippets.

@spolu
Last active December 22, 2021 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spolu/92f8f7f4ab5ac7444d1d to your computer and use it in GitHub Desktop.
Save spolu/92f8f7f4ab5ac7444d1d to your computer and use it in GitHub Desktop.
Productivity note-taking in the terminal
n() {
if [ $1="today" ];
then
$EDITOR ~/notes/`date +%y%m%d`
else
$EDITOR ~/notes/"$*"
fi
}
nls() {
ls -c ~/notes/ | grep "$*"
}
ns() {
egrep -RHi "$*" ~/notes/*
}
nc() {
cat ~/notes/"$*"
}

These bash functions slightly improved from[0], once added to your .bashrc, will enable your bash with powerful note-taking and retrieval capabilities:

  • n today opens a note named after today's date YYMMDD
  • n awesome opens a note named awesome
  • ns git will search for all references to git in your notes
  • nc awesome will dump the content of awesome
  • nls 06 will list all notes that contain 06 in their name
stan@st-stan1:~$ ns git
/home/stan/notes/git:## git checkout and track a remote branch
/home/stan/notes/git:  git fetch origin jim-orders-collapsetax
/home/stan/notes/git:  git checkout -t origin/jim-orders-collapsetax
/home/stan/notes/150612:  git config branch.*branch-name*.rebase true
/home/stan/notes/150612:  git config branch.autosetuprebase always --global (or .gitconfig)
/home/stan/notes/150425:  git grep -l 'original_text' | xargs sed -i 's/original_text/new_text/g'

[0] http://lifehacker.com/5592047/turn-your-command-line-into-a-fast-and-simple-note-taking-tool

@jmb0z
Copy link

jmb0z commented Aug 14, 2015

[ $1="today" ] - are you serious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment