Created
November 7, 2020 18:51
-
-
Save Mindstormer619/bdfe433fee015dfb40b1aa458ab2c513 to your computer and use it in GitHub Desktop.
To be placed in bashrc
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
#!/bin/bash | |
### Add or edit worklog entry -- uses VSCode in PATH | |
### Usage: wlog [dateString] | |
function wlog { | |
local wlogFolder="/d/Workspace/Worklog" | |
if [ -z "$1" ]; then | |
local curdate=$(date +"%Y-%m-%d %a") | |
else | |
local curdate=$(date -d "$1" +"%Y-%m-%d %a") | |
fi | |
if [ -z "$curdate" ]; then return 1; fi | |
# Creation of monthly folder (2020-12) | |
local curFolder="$wlogFolder/${curdate:0:7}" | |
[ ! -d "$curFolder" ] && mkdir "$curFolder" | |
# Create or edit log file | |
local curFile="$curFolder/${curdate:8:2}.md" | |
if [ ! -f "$curFile" ]; then | |
cat <<-EOF > "$curFile" | |
# $curdate | |
## Log | |
## Appendix | |
EOF | |
fi | |
code --add "$wlogFolder" "$curFile" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment