Skip to content

Instantly share code, notes, and snippets.

@Mindstormer619
Created November 7, 2020 18:51
Show Gist options
  • Save Mindstormer619/bdfe433fee015dfb40b1aa458ab2c513 to your computer and use it in GitHub Desktop.
Save Mindstormer619/bdfe433fee015dfb40b1aa458ab2c513 to your computer and use it in GitHub Desktop.
To be placed in bashrc
#!/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