new workflow who dis (aka using bashblog locally on windows) 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](http://tilde.club/wiki/git.html). 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](https://tildegit.org/club/bashblog). 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](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) 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