Skip to content

Instantly share code, notes, and snippets.

@isacikgoz
Created January 19, 2019 16:47
Show Gist options
  • Select an option

  • Save isacikgoz/99df7ef499077a863b7f6e4233e3a459 to your computer and use it in GitHub Desktop.

Select an option

Save isacikgoz/99df7ef499077a863b7f6e4233e3a459 to your computer and use it in GitHub Desktop.
note taking from commandline
note() {
# start a new heading and append from stdout
file_name=$HOME"/Documents/notes.md"
# get the date for datestamp
cur_date=$(date +"%Y-%m-%d")
# get the time for time
cur_time=$(date +"%H:%M:%S")
if [ ! -z "$1" ]; then
# clear
echo "" >> $file_name
echo "## $cur_date $cur_time $@" >> $file_name
cat $file_name
cat - >> $file_name
clear
cat $file_name
# append to file from stdout
else
# clear
cat $file_name
cat - >> $file_name
clear
cat $file_name
fi
}
notes() {
cur_dir=$(pwd)
if [ ! -z "$1" ]; then
# commit and push if args are exactly "push"
if [ "$1" = "push" ]; then
cd "$HOME/Documents"
git add -A
git commit -m "update notes"
git push
cd $cur_dir
# pull from github if args are exactly "pull"
elif [ "$1" = "pull" ]; then
cd "$HOME/Documents"
git pull
cd $cur_dir
# open vim to search of the args
else
escaped=$(echo "$@" | sed s/\ /\\\\\ /g)
echo $escaped
vim +/"$escaped" "$HOME/Documents/notes.md"
fi
# just open the notes
else
vim + "$HOME/Documents/notes.md"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment