43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
from subprocess import run, Popen, DEVNULL
|
|
from datetime import datetime
|
|
from pathlib import Path
|
|
import random
|
|
import sys
|
|
|
|
current_date = datetime.now().strftime('%Y-%m-%d')
|
|
current_time = datetime.now().strftime('%H:%M:%S')
|
|
|
|
journal_path = Path.home() / 'workspace' / 'journal'
|
|
|
|
target_page = journal_path / f'{current_date}.md'
|
|
|
|
script_path = Path(__file__).parent
|
|
|
|
habits = '\n'.join([f'[-] {x}'
|
|
for x in (script_path / 'habits').read_text().strip().split('\n')])
|
|
|
|
words = (script_path / 'godword').read_text().strip().split('\n')
|
|
godword = '\n'.join(' '.join(random.choice(words)
|
|
for a in range(10)) for _ in range(2))
|
|
|
|
if not target_page.exists():
|
|
Popen(
|
|
['bash', str(script_path / 'backup-script.sh'), current_date+'.zip'],
|
|
cwd=str(journal_path), stdout=DEVNULL, stderr=DEVNULL
|
|
)
|
|
|
|
target_page.write_text(f'''\
|
|
# {target_page.stem}
|
|
|
|
Godword:
|
|
{godword}
|
|
|
|
Habits:
|
|
{habits}
|
|
''')
|
|
|
|
with open(target_page, 'a') as fp:
|
|
fp.write(f'\n{current_date} {current_time} ')
|
|
|
|
run(['nvim', str(target_page), '+'])
|