Using Visual Studio Code Raspberry Pi Network Share [Mac]
This post is not describing how to run Visual Studio Code on the Pi. This post shows you how to create a network share on your Pi where your scripts reside so that you can edit them from your computer (this post is aimed at Mac users, go here to setup visual studio code for Windows).
The first thing you want to do, is ensure that you have Visual Studio Code installed on your Mac. You can install plugins you require specifically, but I recommend this Python plugin as Python is usually the goto language with Pi development.
First, update the packages that are installed on the Pi by entering the following in the terminal:
> sudo apt-get update
Creating the Network Share
To allow our Mac to see a network share on the Pi, we must first install Netatalk., To do this, we simply use the Raspbian package manager “apt-get”. Here is the command to install Netatalk
> sudo apt-get install netatalk
apt-get will start installing Netatalk upon pressing enter.
Note: You may need to press “Y” when it asks you to confirm the install.
Surprisingly, that is all there is to creating a network share on the Pi (for Mac). Some users may want to reboot their Pi at this point, although it isn’t strictly necessary. If you would like to check that you can access the Pis files, open up Finder and go to your network locations.
You should see a computer with the name “raspberrypi” (or whatever you have called your Pi, if you had changed it’s name using raspi-config).
Upon double clicking the raspberrypi computer, you will need to click “connect as” in the top right corner of the Finder window.
This will bring up a prompt for a username and password. This is basically the user you wish to log in as. Assuming default settings, this is usually “pi” and “raspberry” as the username and password respectively.
Upon logging in, you will see the home directory of the user you are logged in as.
Using Visual Studio Code
Now that we have Visual Studio Code installed on our Mac, and have access to the Pis home directory (where we save our scripts) we can start to edit our code!
Simply drag a file from the Raspberry Pi network share into Visual Studio Code. Any changes you make and save will be updated on the Pi itself.
Alternatively, you can open a folder from within Visual Studio code by clicking “file -> open folder” and navigating to the folder on the Pi that you want to open.
Nick Cullen is a software developer living in South Wales, UK.
He is primarily focused around coding in C++ and C# and loves tinkering with new programming languages and technologies.
A key technological interest of his is Mobile Development mainly in Xamarin and most recently using Flutter and Dart. Through this interest, he has released one app so far: Prog on both iOS and Android
View all posts by Nick