Rafi Khan

Senior Software Engineer | Ottawa, Canada

Supporting society through innovation

Experimenting with Remote Development using mosh + tmux + emacs

Emacs running inside tmux running inside a mosh shell running inside MobaXterm ... its turtles all the way down
Emacs running inside tmux running inside a mosh shell running inside MobaXterm … its turtles all the way down

Today I wanted to write a fun post showing you how I write code. I’m someone that likes to change their tooling often. There are a lot of ideas out there about how we should write code, and I think being curious and trying out new things can be fun and informative. Sometimes I don’t add a tool into my toolbox, but I always leave with new ideas. With enough experimentation you can mold your tools to best fit how you work and what you work on.

Today I am writing this post from my Thinkpad X1 Yoga 1st Generation. This is a laptop I got back in mid-2020 when my 2015 Macbook Pro was starting to show its age. The thinkpad is running Windows 11 and works really well for browsing, research and office/document editing. But you have to remember this machine was released back in 2015 and comes with a dual core 6th gen i7. We do so much more on our machines now, with desktop-like browser apps and browser-like apps on the desktop through Electron and similar. Luckily, my 16 GB ram on this laptop is taking me a lot further than the 8GB on the Macbook did. But it’s still pretty slow… I’ve given up running docker or virtual machines for example. It’s just not a good idea to share your 2 processors between so many apps, browsers and then VMs? forget about it.

I’ve been doing all of my work remotely connected to my desktop server. This workstation is an XPS 8950 with 32GB ram and a beefy i9 with 16 Cores / 24 Threads. I truly love this machine, but being a desktop I can’t take it with me when going to meetings, working on the road or just wanting to shift to the couch or bed for a bit. I know I should probably stay in my home office with the ergonomic chair and standing desk. But come on, sometimes you’re just tired and want to kick back or get a change of scenery, but also excited to keep going and figure out that last error before pushing to production (half-joking).

The power of my desktop server, paired with my light weight laptop seems like what I want. Now… how to get this working. I tried a few different solutions such as VNC, ssh xforwarding and x2go. After a while I realized that forwarding the graphics wasn’t going to give me the instant feedback I crave. Maybe it’s just me but when I’m writing code or debugging a server I need to in tune with the machine and tools. Any significant delays between my thought to typing/clicking to seeing a result leads to frustration and eventually my flow state is broken. On that note, I’ve been told I can disappear into my laptop when I really get focused, sometimes you just have to come poke me to get my attention!

After all the experimentation, there was one area left. Why don’t I just move all of my work to the terminal? I already spend 80% (made up statistic because why not?) inside emacs gtk gui and tmux, and the browser can run on my laptop just fine as long as all the heavy development servers, databases, docker containers and virtual machines are shoved on to the workstation.

Now I could tell I was on to something… after all people having been using ssh for remote operations and development for decades. I made a few tweaks.

Currently I’m using mosh + tmux + emacs. All of this is running inside of MobaXterm. Oh also, I use tailscale so I can ssh/mosh into my workstation from anywhere I have internet access.

I’m thankful to all of the developers and users that have built, tested and documented how to get these tools working well together. I would not be able ot be as productive without your hard work.

Please reach out if you want to chat or have any questions!