Skip to content

Instantly share code, notes, and snippets.

@Dru89
Created October 16, 2015 06:14
Show Gist options
  • Save Dru89/50b53ce6c6877b77b319 to your computer and use it in GitHub Desktop.
Save Dru89/50b53ce6c6877b77b319 to your computer and use it in GitHub Desktop.
#############
# NOTE TAKING
function n() {
NAME=$1
if [[ "$NAME" != *.md ]]; then
NAME="${NAME}.md"
fi
${NOTES_EDITOR:-$EDITOR} "${NOTES_DIR:-$HOME/.notes}/$NAME"
}
function ngrep() {
GREP=$((command -v ag >/dev/null 2>&1 && echo "ag") || \
(command -v ack >/dev/null 2>&1 && echo "ack") || \
echo "grep")
$GREP "$*" ${NOTES_DIR:-$HOME/.notes}
}
function nls() {
if [ $# -eq 0 ]; then
ls -c ${NOTES_DIR:-$HOME/.notes}
else
GREP=$((command -v ag >/dev/null 2>&1 && echo "ag") || \
(command -v ack >/dev/null 2>&1 && echo "ack") || \
echo "grep")
ls -c ${NOTES_DIR:-$HOME/.notes} | $GREP "$*"
fi
}
compctl -f -W ${NOTES_DIR:-$HOME/.notes} n
compctl -f -W ${NOTES_DIR:-$HOME/.notes} nls
compctl -f -W ${NOTES_DIR:-$HOME/.notes} ngrep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment