Remote Development on Pi Zero
I recently purchased a Raspberry Pi Zero W because I typically don’t use all the peripherals that come with the other models. I recently used VSCode environment with remote development with the intent of using it on my Pi Zero however it turns out the architecture is not supported. Since I’m connecting to the Pi over Wifi, I tried both vim and neovim but it lagged and it wasn’t a great experience. Nano works just fine being as light weight as it is but I prefer to not write entire programs in it. The best solution I found was our dear friend rsync.
On my main computer, I have a folder where I maintain all my raspberry pi projects. I created a script to easily update remote files on my develpment PC to the pi. This solution is effortless by simply running the command pisync
with I’ve stored in my bin
. I’ve written it so it only copies only updated files as you make tweaks or additions to a project. If no arguments are passed, it will use the current directory. Alternatively, you can pass a file or path and it will copy over the file or directory recursively. It syncs the data to the home directory on the pi.
This was a simply, efficient solution I found giving VSCode didn’t support remote development on the Pi Zero.
#!/bin/bash
# Checks sets file based on path or file passed
# Otherwise uses current working directory
if [ $1 -z ]
then
FILE=$(pwd)
else
FILE=$1
fi
# Syncs the folder to the pi home directory.
# Only updates changed files
if [ -e $1 ]
then
echo "Syncing $FILE to pi..."
rsync -rP --update $FILE pi@raspberrypi.local:/home/pi/
else
echo 'File or path not found'
fi