-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtouchlabnote.sh
More file actions
executable file
·51 lines (39 loc) · 1.01 KB
/
touchlabnote.sh
File metadata and controls
executable file
·51 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# USAGE:
# labnote.sh [TITLE]
# take first command line argument
TITLE=$1
# find file with highest num prefix in current dir, return just the num
HIGHEST_NUM=$(fd -d1 "^[0-9]+" | tail -n 1 | sed -E 's/^([0-9]+)[_-].*/\1/')
# if no previous file, set number prefix to 00
if [[ -z $HIGHEST_NUM ]]; then
HIGHEST_NUM="00"
fi
# increment for next number
NEXT_NUM=$((HIGHEST_NUM + 1))
# set new prefix for new file (requires printf for leading zeros)
FILE_PREFIX=$(printf "%02d" ${NEXT_NUM})
# set filename
FILENAME="${FILE_PREFIX}-${TITLE}-$(date -u +%Y%m%d).md"
# create new file
touch "${FILENAME}"
echo "---
title: '${TITLE}'
author: 'James Lingford'
date: '$(date -u +%Y-%m-%d)'
toc: true
format:
html:
code-tools: true
code-fold: true
code-summary: 'Show code'
code-copy: true
html-math-method: katex
embed-resources: true
theme:
light: default
dark: darkly
jupyter: python3
---
## Introduction
" >>${FILENAME}