4 ms·
Or, here's an even better alias. alias jim=' \ journaldir="$HOME/journal" ; \ year="`date +%Y`" ; \ yearpath="$journaldir/$year" ; \
by blackrock 6y ago
Or, here's an even better alias.
alias jim=' \
journaldir="$HOME/journal" ; \
year="`date +%Y`" ; \
yearpath="$journaldir/$year" ; \
[[ -d "$yearpath" ]] || mkdir -p $yearpath ; \
jfile="log_`date -I`.md" ; \
jfilepath="$journaldir/$year/$jfile" ; \
header="# log_`date -I`\n\n# Highlights:\n\n" ; \
[[ -f "$jfilepath" ]] && echo "Opening log: $jfilepath" || { echo "Creating new log: $jfilepath" ; echo -e "$header" > $jfilepath ; } ; \
vi $jfilepath ; '
Copy this to your .bash_aliases file. It's fully automatic. It'll create the directories automatically.
This will now create a /home/user/journal/YEAR/journalfile.md. It's now separated by year, so that you can run this forever, and have a maximum of 365 files per year directory.
This is a markdown file. And in the header variable, I had it fill in the new file with some basic headers. You can edit this yourself to add more.
Try it out, and let me know.
- gtt 6y agojim date: illegal option -- I on macos
- blackrock 6y agoIt seems Bash on Mac doesn't work quite the same as Linux. Try this instead. It works for me. Let me know. Copy it to your ~/.bash_aliases. And source it. alias jim=' function _jim() { journaldir="$HOME/journal" year=`date "+%Y"` today=`date "+%Y-%m-%d"` yearpath="$journaldir/$year" [[ -d "$yearpath" ]] || mkdir -p $yearpath jfile="log_$today.md" jfilepath="$journaldir/$year/$jfile" header="# Log: $today\n\n# Highlights:\n\n" [[ -f "$jfilepath" ]] && echo "Opening log: $jfilepath" || { echo "Creating new log: $jfilepath" ; echo -e "$header" > $jfilepath ; } vi "$jfilepath" }; _jim'