Skip to content

Instantly share code, notes, and snippets.

@rouxcaesar
Created November 15, 2019 21:12
Show Gist options
  • Save rouxcaesar/11213276790909eca176aaaed9841b67 to your computer and use it in GitHub Desktop.
Save rouxcaesar/11213276790909eca176aaaed9841b67 to your computer and use it in GitHub Desktop.
Copy of `dn` CLI tool with my own extensions. Source: https://github.com/tomlockwood/dn
export DN_PATH=~/internal-knowledge/dn
# Writes a bullet-pointed string to a file with today's date in YYYY-MM-DD format in the ~/internal-knowledge/dn/ folder.
dn() {
echo " * $1" >> $DN_PATH/$(date "+%Y-%m-%d")
}
# Does the same as dn(), but the first argument is the filename. This can be used for future notes i.e. dno 2030-10-01 "I died".
dno() {
echo " * $2" >> $DN_PATH/$1
}
# Edit a note in vim for a given date. i.e. dnoe 2019-11-02. If no date is passed i.e. dnoe then a file selection prompt appears in vim.
dnoe() {
vim $DN_PATH/$1
}
# Displays today's notes.
dnt() {
echo $(date "+%Y-%m-%d")
cat $DN_PATH/$(date "+%Y-%m-%d")
}
# Edit today's notes in vim.
dnte() {
vim $DN_PATH/$(date "+%Y-%m-%d")
}
# Displays all files, or when an argument like 2019-10 is passed, ~/internal-knowledge/dn/2019-10*.
dnview() {
find $DN_PATH/$1* -type f -exec basename {} \; -exec cat {} \;
}
# Displays strings from all files that contain passed in argument. Ex: dnlist TODO
dnlist() {
dnview | grep "$1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment