Skip to content

Instantly share code, notes, and snippets.

@alexjj
Created May 11, 2015 14:24
Show Gist options
  • Save alexjj/dd9764efa60983ec9f35 to your computer and use it in GitHub Desktop.
Save alexjj/dd9764efa60983ec9f35 to your computer and use it in GitHub Desktop.
Keep a note
# Note
note () {
# if file doesn't exist, create it
if [[ ! -f $HOME/.notes ]]; then
touch "$HOME/.notes"
fi
if ! (($#)); then
# no arguments, print file
cat "$HOME/.notes"
elif [[ "$1" == "-c" ]]; then
# clear file
printf "%s" > "$HOME/.notes"
else
# add all arguments to file
printf "%s\n" "$*" >> "$HOME/.notes"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment