Git-powered idea logging

Sam Kavanagh

29 May 2019

Description

Example Usage

idea command

[sam@samantha] λ idea "This repository"
Idea added

ideas command

[sam@samantha] λ ideas
===============
= My Idea Log =
===============
Mon May 27 08:22:17 NZST 2019 
This repository

Mon May 27 08:27:31 NZST 2019 
Oh look another cool idea

Setup & Code

  1. As this code uses Git, you’ll want to initialize a Git repository somewhere (which will do nothing but store your idea-log file). Personally I used ~/Documents/ideas.

     cd ~/Documents/ideas && touch idea-log && git init
     # Now set your repo upstream tracking
    
  2. Now simply save the script file below somewhere, and source it in your .bashrc

     function idea() {
         cd ~/Documents/ideas # cd to idea-log repo directory
         echo -e $(date) "\n$1\n" >> idea-log # Timestamp + add idea to the idea-log file
         git commit -am "$1" --quiet # Silently commit (commit msg=idea) the change
         git push --quiet # Silently push the idea
         cd - > /dev/null # Silently cd back to the previous working directory
         echo -e "Idea added"
     }
    
     function ideas() {
         cd ~/Documents/ideas # cd to idea-log repo directory
         git pull --quiet # Pull any new ideas that have been added
         cat idea-log # Read the idea log
         cd - > /dev/null # Silently cd back to the previous working directory
     }