Last active
November 7, 2021 21:43
-
-
Save dkaslovsky/010fd26c4d0975639a5c286fa631d6c9 to your computer and use it in GitHub Desktop.
Command line functions to go with github.com/dkaslovsky/textnote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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