• Home
  • Blog
    • Programming
    • Art
    • Recipes
    • Home Automation
    • Life
    • Friday Faves
    • Books
    • Writing
    • Games
    • Web Accessibility
    • Advent of Code
  • Projects
  • GLSL Shader Art
  • Glitch Art

  • Github
  • Bluesky
  • Mastodon
  • Duolingo
  • LinkedIn
  • RSS
  • Bridgy Fed

mary.codes

Web development, art, and tinkering with fun projects. JavaScript, Python, WebGL, GLSL, Rust, Lua, and whatever else I find interesting at the moment.

How I blog from my phone using Termux

Mary KnizeBlog iconNov 8th, 2022
2 min read

Programming

I now have everything set up so I can remote into my blogging machine.

Once upon a time, I had a Raspberry Pi 400 that was running Home Assistant. While it worked relatively well, I kept encountering problems after losing power. I also felt like I wasn't using the system to its fullest. I was basically wasting the built-in keyboard by keeping it tucked away in a corner.

Within the past week, I wiped the Pi, made a bootable external hard drive, and cloned my blog from GitHub. Now, I have a portable system with a keyboard that I can use to quickly spin up a blog post. It's always on, and as long as there aren't any critical errors or power loss, it's always in gatsby develop mode.

My current blog setup

It's great for blogging from my desk, but I can also remote in with my phone or Chromebook, in case I want to blog something quickly on-the-go (like my mini-rant about Dreamlight Valley).

Since everything is running on the Raspberry Pi, I didn't need to install much on Termux. I've had Termux set up for a while now, but I think all you really need is Vim (or whatever CLI text editor you like).

I had to run termux-setup-storage according to these instructions because I want to be able to access my photos and screenshots from within Termux. I use scp to transfer photos to the correct img/ directories for my posts.

Copying images

As you can see, I copy images with this formula from within the image's directory: scp [image filename] [remote user]@[remote IP]:[path to img directory]/[new image filename]. It's a lot to type, but it's faster than walking into another room and copying files with a USB cable, or uploading and downloading images from Google Photos.

The actual post editing is easily done through SSH. The incantation for that is ssh [remote user]@[remote IP]. Eventually, I`ll get SSH keys setup for additional security and so I don't have to use my password all the time.

Editing with Vim

Using Vim with Termux is definitely not the ideal writing experience. There's no autocomplete and typing on the phone keyboard is a pain. However, it does allow me to touch the screen wherever I want to put the cursor, so I can use that in addition to the Vim movement keys, which speeds up editing.

The trick to previewing my changes is to have Gatsby running in develop mode with the host machine's IP specified as the host instead of localhost. In this case, I've run gatsby develop --host 192.168.0.37 on the Raspberry Pi, and I can now visit 192.168.0.37:8000 on any device connected to my network to preview my site. It's also a great way to see how things look on a variety of devices.

Once I'm finished, I can simply commit my changes with git and push them to GitHub, and Gatsby Cloud does the rest!


Other Programming posts

How I'm organizing my work in 2024

Finding the Design Engineer within the Full-Stack Developer

Displaying the current Git branch in my Linux terminal prompt

Generating a 3D map with OpenStreetMap and A-Frame

Translating OpenStreetMap data to HTML5 Canvas with Rust and WebAssembly

Latest posts

I started painting again

100 days of Japanese on Duolingo

How I'm organizing my work in 2024

Watch the documentary 'Good Night Oppy' if you're feeling science-y

Sculpted robo-goldfish, a rainbow office building, and a look inside click farms