Skip to content

Instantly share code, notes, and snippets.

@rosvik
Last active September 3, 2021 22:35
Show Gist options
  • Select an option

  • Save rosvik/db912007369868810ec6fc4496fad717 to your computer and use it in GitHub Desktop.

Select an option

Save rosvik/db912007369868810ec6fc4496fad717 to your computer and use it in GitHub Desktop.
infinote v0.1
#!/usr/bin/env bash
# Path to infinote git repo
INFIPATH="$HOME/Git/infinote/"
# Path to the note file
INFIFILE="$HOME/Git/infinote/infinote.md"
# Author of automatic git commits
AUTHOR="infinote <[email protected]>"
# Current timestamp formated as "Wed May 12 20:59:43 CEST 2021"
DATE="$(date)"
# Get the number of lines in document for cursor placement
CURSORPOS=$(echo $(wc -l $INFIFILE | awk '{ print $1 }')+3 | bc -iq)
# Add timestamp comment to end of file
echo "---" >> $INFIFILE &&
echo "###### $DATE" >> $INFIFILE &&
# Open in editor with cursor position
nano +$CURSORPOS $INFIFILE &&
#vim +$CURSORPOS $INFIFILE &&
#micro $INFIFILE:$CURSORPOS &&
#subl --wait $INFIFILE:$CURSORPOS &&
#code --wait $INFIFILE:$CURSORPOS &&
# Git pull, commit and push
cd $INFIPATH &&
git add $INFIFILE &&
git commit --author="$AUTHOR" -m "(infinote) Automatic commit $DATE" &&
git pull --no-edit &&
git push &&
cd - # Return to previous directory
@rosvik
Copy link
Author

rosvik commented May 13, 2021

Installing:

  1. Run
mkdir infinote &&
cd infinote &&
git init &&
curl -O https://gist.github.com/rosvik/db912007369868810ec6fc4496fad717/raw/5b85bf98238f7bc02773659425536ff02836a4cd/infinote.sh &&
chmod +x infinote.sh &&
ln -s "$PWD/infinote.sh" /usr/local/bin/infinote &&
nano infinote.sh
  1. Set INFIPATH (line 4) to the path of the folder that was just made.
  2. Set INFIFILE (line 7) to the path of the file you want to make your notes in.

Running:

$ infinote

Demo:

infinote.mov

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