introducing bashlessblog

January 19, 2024 — ~enamel

Avid readers of this blog (lol) will probably notice that after posting a whole deal on a workflow that was supposed to help my posting frequency ... I stopped posting. So what happened? Well my new fancy workflow didn't work due to one annoying issue. Git does not save file metadata and bashblog uses file modified dates when generating its output. Basically I ended up breaking the whole blog by git'ing stuff around, it made everything look like it was created on the git clone date.

So what is the totally logical solution? To port the entire thing into a new language of course!

bashlessblog: It's bashblog, but less.

When my attempts at modifying bashblog to use the embedded timestamps it makes in the posts was a failure I decided to rewrite the whole thing. I had a few big wants that drove this decision:

  • I wanted to use modern editors
  • I wanted to use the software on windows
  • And I wanted to be able to put the whole thing in git without breaking timestamps

The outcome is a small .net application that is compatible with existing bashblogs but geared towards a static site generator workflow.

In the process I ended up learning enough about bash to have made the initial change to timestamps. But I am very happy with the result and I hope I never ever have to think about bash again.

Builds are available here for windows and linux, and require the .net 8 runtimes. I may look into creating some native AOT builds in the future so the runtime is not required.

tags: bashlessblog, bashblog, blog, dev, windows, linux

new workflow who dis (aka using bashblog locally on windows)

October 20, 2022 — ~enamel

Recently a friend asked me why I hadn't been updating my blog. After getting over the shock of finding out someone actually reads this, the answer is really simple. I dislike writing and developing in a terminal.

After the nostalgia of creating a site and a blog on tilde.club using the terminal wore off, I knew I was going to have to work on getting a local development environment going on my daily driver. I needed to reduce the amount of friction if I was going to keep up with updates on the blog and the tilde.club site.

The rabbit hole

The main part of the site I wanted to make easy to update was this blog. I considered replacing it with a different static site generation tool, but I didn't find much available on Windows. I am sure there is something out there but the simplicity of bashblog is unmatched and I didn't want to learn a new framework to make a blog when I was happy with the output of a simple bash script.

So I investigated a few options to run in a "mixed mode", doing everything on the tilde.club server and only editing the blog posts locally using something like SFTP and SSHFS. These solutions seemed clunky so I moved to figuring out how to recreate a linux environment that would allow me to run bashblog locally. I considered porting bashblog to PowerShell, and may still do that in the future, but this was a perfect opportunity to play with WSL - Windows Subsystem for Linux.

Microsoft's embrace of Linux is one of the most surprising things to come out of Redmond in ages (and I have been developing for Windows for a long time). In retrospect, it shows how big of a transition they have made away from Windows as a product. They are now focused on selling services and in order to sell services they have leaned into one of their strengths, supporting developers. And in that effort to go to where developers are, Linux can now be run as a part of Windows and the two co-exist in a surprisingly seamless manner.

Creating a local tilde.club development environment on Windows

WSL setup

The first thing to do is to enable the WSL subsystem, it is disabled by default. 1. Enable virtualization support in the BIOS 2. Enable "Virtual Machine Platform" in Windows 3. Enable "Windows Subsystem for Linux" in Windows

Next is to install the needed components for WSL, along with a distro. By default Ubuntu is installed from the Windows Store automatically, but you can install any distribution you want from a tar file.

wsl --install

I recommend using the same username for the WSL distro as used in tilde.club.

Git

Git is the connective tissue between tilde.club and your local environment. It will be used to sync your local dev environment to the tilde.club server.

First, commit your tilde.club's public_html directory to Git. If you need help with this, see How To Use Git.

In your WSL instance, from your home directory clone your public_html repo. Your local file structure should match your tilde.club structure so you don't run into issue with bashblog.

Unfortunately Git does not store timestamps which breaks bashblog. To restore timestamps and set them to the time your posts were committed you can install and use the following tool:
sudo apt install git-restore-mtime
git restore-mtime

bashblog

Using Git, clone bashblog into your home directory. I used this version customized for tilde.club. To install the script, use 'sudo make install' from the cloned bashblog repo.

Modify the .bashrc file to have the line 'export EDITOR=nano' to appease the script. We won't be using Nano (unless you want to) but we need this for the script to work without modification.

Finally, use 'bb post' then save this file as a draft to use as a template later.

IDE setup

Visual Studio Code makes working within WSL installs extremely easy. By installing the Remote Development Extension Pack you can work inside the linux environment from Windows seamlessly, including all of the features you wouldn't get from SFTP like code completion and intellisense. This is because VS Code runs a server on the Linux environment that does all the heavy lifting and uses the VS Code as the GUI via SSH.

Remote Development Extension Pack

This gives you code editors with language support, a terminal, Git integration, etc. in one package. This is the secret sauce that makes this workflow so easy for me.

From your public_html directory in WSL enter the command 'code .' and VS Code will open in Windows and connect to the WSL instance.

Workflow

Now that you have everything setup and VS Code is open and connected to your local copy in WSL, we are going to be abusing the draft functionality in bashblog.

  1. Create a copy of the template created in the drafts folder
  2. Modify the copied template with the blog content
  3. Run > bb post <copied template filename>
  4. Save and exit in Nano
  5. Post, edit, or save as draft
  6. Commit and push in Git locally
  7. Pull in Git on tilde.club

tags: WSL, tildeverse, personal, dev, linux, windows