Home Brewing and Tech Gizmos

Hand Crafted Beer with a touch of IoT

Using a Desktop Editor for Raspberry Pi Development

If you, like me, find your development speed slowing down significantly when you have to rely on the available command line editors on the Raspberry Pi like ‘nano’, ‘Emacs’, ‘Vim’, etc. then maybe this blog post might help.

Before moving on, I just want to make it clear that I have no intention on bashing on my favorite command line editor ‘nano’ which is always there when I need it. It’s good for simple editing tasks like changing parameters in a settings file or similar. But it do falls short when larger and/or multiple files need to be edited.

On the other hand I would never even consider trying my luck in ‘Emacs’ or ‘Vim’. It’s probably not by coincidence that the Stack Flow question “How do I Exit the Vim Editor?” has more than 2 million views.

As far as I know, there are not really any decent desktop editors available for the Raspberry Pi. And if you are developing on a faceless Pi like the Zero W, this would not even be an option. You could of course develop your code on your desktop computer and the push it back and forth with ‘scp’. But that still has its limitations as you would always have to remember to copy the right files in the right direction.

Instead I want to use my favorite desktop editors like Xcode, Typora and others. So seen from the desktop side this mean that I need to be able to access the files on the Raspberry Pi directly from the editor on the desktop.

Basically, there are at least two options for this:

  • Using SSHFS to mount a virtual drive on the local desktop which uses SSH and SFTP for the underlying transfer.
  • Setting up the Raspberry Pi as a Samba file server to share its files via the standard SMB/CIFS protocol.

The advantage of using SSHFS is that it doesn’t require any changes on the Raspberry Pi. On the other hand it requires installation of kernel extensions to the macOS file system in order to add support for additional file systems. In addition to this, there may also be synchronization problems in case you edit the same files on both the desktop computer and on the Pi.

Samba on the other hand requires installation of additional software on the Raspberry Pi. The biggest advantage is that once, the Samba share has been configured it will be possible to connect and get access to these files from any Mac or Windows computer on the network. I have therefore chosen this approach.

Setting up Samba on Raspberry Pi

Samba is available from the standard Raspbian repository via the ‘atp-get’ package manager. In order to install it on the Raspberry Pi, enter the following on the command line:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install samba samba-common-bin

Next step is setting up the shared drive. Since this will be used for development on the Pi, I’ll set it up to share the entire content of the ‘pi’ user’s home directory. Enter the following command to edit the Samba configuration file:

$ sudo nano /etc/samba/smb.conf

Add the following to the end of the configuration file to share the directory ‘/home/pi’ as ‘Pi’:

[Pi]
path = /home/pi
comment = No comment
writeable=Yes
create mask=0777
directory mask=0777
public=no

Save the file by pressing ctrl+X, then Y followed by Enter. After you edit the file, you can verify if everything has been defined properly by entering the following command:

$ testparm

If everything looks OK, it’s time to enable access for the user ‘pi’. It is done via the following command:

$ sudo smbpasswd -a pi

You can choose the same password as the local ‘pi’ user, or you can define a different. The Samba server is now configured and ready to be restarted with the new configuration using the following command:

$ sudo service smbd restart

Everything should now be ready for accessing the Raspberry Pi share. From a Mac you can access the Pi by going to the Finder and select the menu item “Connect to Server…” (or just hit ⌘-K). Then enter the following in the dialog:

smb://Pi4/Pi

Log in as the user ‘pi’. The ‘/home/pi’ directory from the Raspberry Pi is now mounted as a drive named ‘Pi’ on the local computer and you can now use your favorite desktop editor directly on the files on the Raspberry Pi.

2 Replies to “Using a Desktop Editor for Raspberry Pi Development”

Leave a Reply

Your email address will not be published. Required fields are marked *