Tag Archives: editing

How I can edit files on a remote server using Textedit on my Mac through SSH

Posted on December 1 2018

Two years ago, I wrote about how I use Textedit instead of vi, vim, or nano  when editing files  in my macOS terminal. It’s still working well for me, but then I wanted it when remotely logged into other computers. Textmate can do that, but you need ruby on the remote machine and have to move over a ruby script etc. Last month I got a Ubiquity edge router x which I have no regrets with even after taking all the Cisco classes up to CCNP, configuring Cisco routers for 8 months  as an intern for the state, and running my home network off   Cisco   routers for 14 years  since 2004. I also recently  remembered a Nano Pi Neo, I’d been neglecting for 2 years, and between the 2 devices was needing to edit files on them, and the router doesn’t have ruby installed; I wanted my  Textedit. (Imagines a small child throwing a tantrum because they didn’t have their   security blanket.)
I downloaded Transmit from Panic software which is an awesome program, but its price was also a little too awesome for my wallet, so back to the drawing-board. 
I googled around looking for a way to edit files remotely through SSH connections and found out about SSHFS. FUSE is a way to create a file system in user space, or in simpler language,  to create kind of a virtual file system. SSHFS uses FUSE to create a session in-which a specific folder on a remote machine appears in a specific folder on your  machine in front of you, and then keeps them synced together. This lets me use my Textedit cheat to edit files on my mac as I have been doing for 2 years except in addition now they get synced back to the remote machine through SSH. It’s pretty cool, but if using a mac  you’ll need a few extra pieces to do it.
Hard core *nix users probably argue that a mac really doesn’t have BSD unix because it doesn’t have a package manager, but there are a few. Home brew is probably the best now though it had to compete with several others like Mac Ports and Fink for some years before emerging. You will need Home Brew to eventually get SSHFS so here’s the process for getting itFirst you’ll need Xcode command-line tools if you don’t have them already. Paste the following into the terminal:xcode-select –installand decide if you only want the CLI tools or the whole Xcode install. With only 128gb on my MacBook air, I think you can figure out which I chose. The Xcode command-line tools are very nice to have as they give you gcc clang, and other programming goodies.
Next it’s time for Home brew. Paste/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
Next we will need 2 packages before we can get sshfs working.  brew cask install osxfuse

brew install sshfs

Now we can actually make it happen. 
First on your machine make a folder where you want the files from your remote machine to momentarily exist.
Then type something like sshfs username@server-ip:/path-to-folder ~/folder-for-remote-filesObviously typing server-ip won’t work  neither will username but it should be easy to fill in your specific information there.The first time you do it, you will have to answer some questions from the security and privacy preference pane. After you say yes to them, it should work.
It seems to stay connected until the next reboot. You can do anything to those files you want and changes will sync between both devices. It’s very nice.


How I’m Using Textedit beyond VI and VIM to edit files from the Mac os terminal

There’s a joke about the Unix editor vi, that goes something like: I’ve been using vi for so long, because I can’t figure out how to get out of it. Vim, in my opinion isn’t any better. I can appreciate the power these editors have, and they’re really fast for those who are comfortable on them, but I think of documents more fluidly than only 1 line at a time. I can use nano if I have to, but I feel most comfortable in an interface at least as developed as something like notepad or Textedit. Enter another way to cheat in the Mac OS terminal.

Before actually doing this, it’s a good idea to change a few settings in Textedit or bad things might happen.

Bring up the preference in Textedit either through the menus or just press Command-comma.
In the new document tab, select the plain text radio button, also make sure that the check spelling as you type, the check grammar with spelling and the correct spelling automatically check boxes are unchecked. You also want the smart quotes and smart dashes options to be unchecked.

On the open and save tab: you may want the display html text as code instead of formatted text checked. You definitely want the add .txt extension to plain text files unchecked, or things will stop working.

Now that we have that all out of the way…


alias ted=’open -e $1′

Something so easy you can have it working immediately in a brand new squeaky clean install before you even have your most favorite apps up and running. There are awesome editors out there that can also work with files from the command-line that do way more than Textedit could ever dream of, like TextMate and BBEdit, but this is still a nice fix to keep in the toolbox that requires nothing beyond what OS X provides out of the gate.