Skip to content

Commit

Permalink
Quality of life improvements
Browse files Browse the repository at this point in the history
* interoperable sed command
* add gitignore/editorconfig files
* improved logging in weekly hours calculator
* improved logging in the daily entry creation script
  • Loading branch information
ben-basten committed Dec 11, 2023
1 parent def4cc2 commit 21402cb
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.md]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_STORE
.vscode
todo.txt.bak
24 changes: 14 additions & 10 deletions daily.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#!/bin/bash

echo "MAKING DAILY ENTRY"

DATE=$(date +%Y-%m-%d)
WEEKLYDIRECTORY="docs/daily/week-of_${DATE}"

TODAY=$(date)
if [[ $TODAY == Mon* ]] && [ ! -d ${WEEKLYDIRECTORY} ]; then
mkdir $WEEKLYDIRECTORY
echo $WEEKLYDIRECTORY dir created
echo $WEEKLYDIRECTORY dir created.
fi

ACTIVEWEEK=$(ls -l docs/daily | tail -1 | awk '{ print $10 }')
FILENAME="docs/daily/${ACTIVEWEEK}/${DATE}-todo.md"
ACTIVEWEEK=$(ls -1A docs/daily | tail -1)
FILENAME=${DATE}-todo.md
FILE_PATH="docs/daily/${ACTIVEWEEK}/${FILENAME}"

if [ ! -f ${FILENAME} ]; then
if [ ! -f ${FILE_PATH} ]; then
# make new daily entry
cp templates/daily-template.md ${FILENAME}
cp templates/daily-template.md ${FILE_PATH}
echo $FILE_PATH file created.
# add header to daily entry
sed -i '' "1s/^/# ${DATE} TODO \n/" ${FILENAME}
echo $FILENAME created.
sed -i.bak "1s/^/# ${DATE} TODO \n/" ${FILE_PATH}
# For backwards compatibility between GNU and BSD version of sed
rm ${FILE_PATH}.bak
echo Opening new daily entry: $FILENAME
else
echo Opening existing daily entry: $FILENAME
fi

# open in vscode editor
code $FILENAME
code $FILE_PATH
5 changes: 2 additions & 3 deletions jira.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash

# script to replace all instances of this regex (?<!\[)(KEY-(\d){4,5})(?!\)) with [$0](https://mycompany.atlassian.net/browse/$0) in file passed as argument
# Replace "KEY" with your Jira project key
# Replaces matching story numbers in specified file(s) with a markdown link to Jira

# update script to run perl command for all arguments passed to script
for i in "$@"
do
# NOTE: Replace "KEY" with your Jira project key
perl -pi -e 's/(?<!\[)(KEY-(\d){4,5})(?!\))/[$1](https:\/\/mycompany.atlassian.net\/browse\/$1)/g' $i
done
7 changes: 5 additions & 2 deletions pattern.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

# replace spaces with hyphens, make it lowercase
filename=$(echo $1 | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
full_path=docs/patterns/${filename}.md

cp templates/pattern.md docs/patterns/${filename}.md
cp templates/pattern.md ${full_path}

# replace the first line of the file with the pattern name
sed -i '' "1s/.*/# $1/" docs/patterns/${filename}.md
sed -i.bak "1s/.*/# $1/" ${full_path}
# For backwards compatibility between GNU and BSD version of sed
rm ${full_path}.bak

code docs/patterns/${filename}.md
1 change: 1 addition & 0 deletions templates/daily-template.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

## Hours

in @
Expand Down
4 changes: 2 additions & 2 deletions weekly-hours.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

ACTIVEWEEK=$(ls -l docs/daily | tail -1 | awk '{ print $10 }')
ACTIVEWEEK=$(ls -1A docs/daily | tail -1)

echo "ADDING WEEKLY HOURS: ${ACTIVEWEEK}"

awk '/hours/' docs/daily/${ACTIVEWEEK}/* | awk 'sum+=$1; END{print sum " hours total"}'
awk '/hours/' docs/daily/${ACTIVEWEEK}/* | awk 'BEGIN{sum=0}; sum+=$1; END{print sum " hours total"}'

0 comments on commit 21402cb

Please sign in to comment.