Skip to content

Instantly share code, notes, and snippets.

@dkaslovsky
Last active November 7, 2021 21:43
Show Gist options
  • Save dkaslovsky/010fd26c4d0975639a5c286fa631d6c9 to your computer and use it in GitHub Desktop.
Save dkaslovsky/010fd26c4d0975639a5c286fa631d6c9 to your computer and use it in GitHub Desktop.
Command line functions to go with github.com/dkaslovsky/textnote
alias tn='textnote'
tnlatest() {
ls -l $TEXTNOTE_DIR | grep -v 'archive' | awk '{print $9}' | sort -r | head -n 1 | cut -f 1 -d '.'
}
tnls() {
ls -la ${TEXTNOTE_DIR}
}
tncat() {
local latest=$(tnlatest)
cat "${TEXTNOTE_DIR}/${latest}.txt"
}
# uses fzf for searching
tnarcat() {
local search=$1
if [[ -z "$search" ]]; then
search="archive"
fi
\ls -d $TEXTNOTE_DIR/* | fzf -1 -q ${search} | xargs cat
}
# uses ripgrep, but standard grep -r should work also
tnsearch() {
rg -i $1 $TEXTNOTE_DIR
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment