--- post_date: 2023-05-09 --- # A new-post script I got to take a new "newpost" script for a spin just now and was really pleased with it. It: - Moves the post file into my gemlog directory, renaming it in the process according to the date and the title, which it pulls from the first H1 in the post. - Adds a link to the post to my index/homepage. I bail out to python for this since it's a little heavier - more on that in a minute. - Alerts Antenna to the index page change. This is probably where 90% of the value comes in. ## Mixing languages Now I'm feeling a little motivated to evict python from this script, because there's some friction in doing this task partly in bash and partly in python. Python isn't the greatest scripting language for one-liners, and using the -c switch isn't really useful any more beyond that. So for now this script (1) creates a tempfile, (2) dumps mostly hard-coded python into it (from a bash HEREDOC), (3) executes it, (4) captures the return code, (5) unconditionally removes the tempfile, and (6) exits the script if the return code was unsatisfactory. That's...not great. Although as I type this I guess I can probably execute "python" directly on a named pipe with bash `<(cat < Note: This was ported from my old gemini capsule, still served on gemini at `gemini.ctrl-c.club/~tjp`