Editing remote files over SSH, using TextMate? - macos

I LOVE using TextMate on my MacBook. It's great.
Unfortunately, I want to edit some files directly on my dev server, since it's difficult to recreate the environment locally. I'm using Git, so one alternative is to just edit locally, git commit, git push, and then git merge, but that's kind of complicated every time I want to make a simple change.
I'd rather just ... use another solution. One thing I tried is mounting a hard drive via MacFusion, and then loading that in an editor. But that's so freaking laggy/slow!
Has anyone cooked up a better solution?

OK - here is the one that works on Mountain Lion.
Go to http://osxfuse.github.com/
Install FUSE for OS X
Install SSHFS for OS X
Then the following commands on your terminal:
mkdir /Volumes/SSHFS
/usr/local/bin/sshfs username#host:/path/to/dir /Volumes/SSHFS
Done.
I would also recommend using the ReMate plugin as pointed out by another user to prevent TextMate from beach-balling every time you refocus it. Link:
ReMate http://ciaranwal.sh/remate

I use Fetch and TextMate for just such tasks. Fetch can be set to use TextMate as an external editor and can even automatically open files in TextMate by double clicking.
Saving the window in TextMate automatically pushes the file back to the server. Of course you would have to commit the changes on the server at a later time.
I'm sure most Mac FTP clients could do the same.

The best thing would be using TextMate's rmate script, follow the link and you'll find the instructions bellow, I recommend it since it will make your life easier and handle all the Nitty-Gritty.

I use the free version of TextWrangler for just this and it works great. I can load and save files over sftp.

The correct answer is to use sshfs and make sure "Perform atomic saves" is checked in the Textmate preferences window. The easiest way to setup sshfs is to use Macfusion. http://macfusionapp.org/.

Try one of these methods.
see: http://wiki.macromates.com/Main/FAQ#projects
also have a look at:
http://www.gnu.org/software/tramp/

You don't need to push every time you make simple changes; git is a distributed version control system, you commit to your local repository for the small changes. You should only push to the remote repository once you finished working on a feature/bug (or for really huge feature, a complete subfeature). Well, that's assuming you can recreate the environment; which apparently you can't.
A decent text editor can have integration with your favorite control version system; if you cannot configure your editor to commit and push from inside your editor, get a decent editor.
An even better editor can be set to save, commit, push, compile, and run your program all in one click or keypress.

If you are not able — for whatever reason — to replicate your environment locally and still want to use TextMate, the FTP client+TextMate combo is the best solution I can think of. MacFusion and all the other similar solutions are neat on the paper but awfully slow.
If you feel adventurous and confident enough to drop the TextMate requirement, SSH+Vim in the terminal works amazingly well.
Are you positive you can't replicate at all your remote environment?

I know this question already has several answers, and it's been a while, but I wanted to also point out DokanSSHFS - This will use SSH to make a local drive of the directory location on the server that you choose. Then you can use your editor of choice to edit the files as if they were on a local disk.

Most of the proposed solutions are centered around sshfs in one form or another. I have tried these solutions, but I found that reliability of filesystem is not always as good as desired.
There is tool called rmate, which allows editing of remote files in text mate.
Use command from ssh session to edit file on the server:
rmate file_name
The readme on github provides easy to follow instructions on how to set it up.

MacFusion is pretty sweet for free - basically ssh-mounting of directories.
http://macfusionapp.org/
Transmit 4 has a similar feature, tho it costs $$.
Try http://ciaranwal.sh/remate/ if it seems slow, as that will disable textmate from refreshing the file list so often.

Use Fuse for OS X http://osxfuse.github.com and the companion package, SSHFS (same URL) and install them. I installed the MacFUSE compatibility libraries from there too, just for good measure.
Then, install http://macfusionapp.org and follow the instructions located here ( https://github.com/osxfuse/osxfuse/wiki/SSHFS ) to configure macfusion to use the newer libraries.
I had trouble getting authenticated with password, so I set up ssh key authentication and used macfusion without password. Works like a charm.

If you do use an IDE, you could just set up an SSH tunnel to your dev server and edit your files from the comfort of your favourite IDE. Saving the files locally would automatically then push the files on the dev server as well
P.S: I am NOT endorsing the use of IDE

You need rmate it works fine to edit files on your server via ssh using TextMate on you local machine.
Github link here

rmate might be another choice. On server side, you type rmate /path/to/file. The file will be transferred to local machine, where you use some editor like Sublime Text or VS Code (TexMate may also work). To use it, one needs to install both server and client.
For server side, there are several ones in various languages. Choose one you like. Here is the Github repo.
On local machine, as far as I know, VS Code and Sublime Text have their extensions to receive files. For VS Code, refer to here. For Sublime Text, refer to here.
On the other hand, Microsoft just announced an official remote editing extension for VS Code (not released yet).

For those remote machines not having ruby or if bash not compiled with /dev/tcp, but has python, this works: https://github.com/scriptmaster/rmate-python
If you have pip:
pip install rmate
or simply:
wget https://raw.githubusercontent.com/scriptmaster/rmate-python/master/bin/rmate
chmod +x ./rmate
mv ./rmate /usr/local/bin/rmate
then rmate /path/to/file
especially if you are in a containerd-os with restrictions (with only python and docker) such as kubernetes-vm or gce-vm
you don't need vs-code-server, atom-editor,

Related

Cross-platform SVN issues, please explain

I am a Mac-based (10.8) web developer, trying to work with other Windows-based developers. They are using SVN, although most of them do not check out files to local repositories. They mostly edit the file on the local server via Explorer, and then use TortoiseSVN shell enhancement to right-click and "commit" what they just edited.
I cannot seem to do this, as my preferred SVN tool Versions (as well as Dreamweaver CS6) require access with the SVN, HTTP, etc. protocols. I get errors trying to use the file system.
So, I am trying the command line, navigating to the file I need to edit, open it, edit, save. I can run svn status on the directory and I see the file status as "M". If I try svn commit -m "updated" myflie.css or similar, I get an error:
svn: Unable to open an ra_local session to URL
svn: Local URL 'file://webstage-01/svn/repository/fc-dev/assets/css' contains unsupported hostname
I looked in the .svn folder "entries" file an see this:
10
dir
20788
file://webstage-01/svn/repository/fc-dev/assets/css
file://webstage-01/svn/repository
2012-06-26T16:08:10.220007Z
20747
JSmith
So it looks like that's where it's getting the path from, which is not a valid MacOS or Unix path.
Suggestions?
It sounds like the local server is already a checked out working directory that everyone is sharing. This is the completely wrong and awful way to do Subversion. In the end, you have no idea who is making the change because they're all using the same client. Plus, there's no guarantee that working clients use the same format of the working directory. If someone has a version 1.6 TortoiseSVN on their system, they could damage that working copy.
The correct way is for everyone to checkout a local copy of what's in that Subversion repository to their local machine (Windows or Mac), and then do their changes there and check it in. You won't have the issue of someone messing up that directory. You know who is making the changes. You won't have an issue of what happens if two people try to make the same changes at the same time. It's the way Subversion is suppose to work.
The Mac has the Subversion command line client. (Assuming you're using Mountain Lion -- the latest release) You need to install XCode (free from the Mac App store), and then in XCode, install the command line tools. Look at the on line Subversion manual and learn how to do the checkout in Subversion, create your own working directory, and check in from that.
There are many options if you want a Mac OS X GUI Subversion client. I highly recommend you look at Pathfinder](http://cocoatech.com/pathfinder/). It has a built in Subversion GUI client, but it also has many Finder enhancements that make it an excellent Finder replacement -- especially for power users. It's $40, but I think it's worth it just for the built in Terminal client.
I don't think you can do that. The svn folders on "local server" were created by a platform-specific tool like TortoiseSVN on Windows. Obviously it will have paths, etc. specific to Windows. You will need to checkout separately and make commits.
Also, BTW, set the EOL property to 'native' so that you do not run into cross-platform EOL issues.

Using SVN for the first time

Not sure if I should be asking here or Server Fault.
Anyhow, I recently started a project at a new job that has SVN installed. I didn't use it even though I was given SSH access with some keygen thing. But now I've done some reading online for beginner's and I'm having a tough time getting past "which svn" after I input a command through SSH. I guess that tells me the path to the repository (which is /usr/bin/svn) but I don't even know how to get to that directory (I'm using Terminal on Mac OS X).
All this makes me feel pretty stupid, since I've never really had to use the terminal to do web projects before and this is my first experience with SVN via SSH (Hell, first time using SSH even).
I have been googling and reading for a weekend now, but I figured someone on here probably has a good idea of where to find the files or to check which are under SVN etc. I think my main problem is finding out how to use the terminal to "get" to the folder I want to be working on.
I did read up on the commands to check if a file is under SVN, check out, update, commit, etc. I would just like to know how to get to these files to do that. Sorry for the noob question and thanks in advance
Bonus points if someone explains the benefits of SSH (I totally understand the benefits of SVN and would love to learn it properly)
You're likely better off using a subversion client. Two of the most popular ones for OS X are http://versionsapp.com and http://zennaware.com/cornerstone/index.php (lately my dev friends seem to like cornerstone more.)
These should let you do all (or nearly all) SVN functions, but by using a GUI. You'll still want to learn the terminology. Take a look at http://svnbook.red-bean.com/en/1.6/svn.basic.html
You want SVN+SSH as it's more secure, but that shouldn't mean you have to use the command line.
Well there is no need to go to the /usr/bin even though svn resides there. /usr/bin is a standard location which is automatically included when the system tries to resolve the location of a file. You should be able to just start using SVN commands like:
svn checkout ...
The benefits of using SVN and SSH are separate questions all together.
svn list --verbose http://host_name/svn_dir will give you a list of the current versioned projects (including revision number and modified date)
svn checkout http://host_name/svn_dir/repository_name projectx will checkout the repo (creating a working copy on your local machine)
I'd recommend the manual here, even if you don't read it to start with and just use it as your first reference point when needed.

Easy FTP publishing for Vim (like Coda)

I've been using Vim (MacVim) exclusively for months now, and I love it. Before using Vim though, I used Coda (I'm on OSX), and the one thing I miss about Coda is the way it marks my files for publishing via FTP whenever I edit them. I can then choose to upload the modified files single files individually, or to publish all of them in one go.
Is there anything that will do this or similar in Vim?
I'm aware netrw can edit directly over FTP, but I have all my sites running locally as mirrors of the online sites, so I need to edit locally and publish files remotely as and when I need. I've Googled for solutions but can't find anything.
I'm far more productive in Vim while in the editor, but having to open up an FTP program and hunt and peck to copy across files as I edit them seperately is a real pain, and makes me less productive overall when working on websites when compared to working in Coda.
Any suggestions welcome :)
Transmit, Cyberduck and YummyFTP (the ones I know) all have their own version of "automated folder syncing" where you work locally and any modified files are uploaded on change: you setup an "observer" and never have to hit a special button or shortcut again.
If you want to only use MacVim you could write a little command that uploads the current file on save: a script that would use the current file's path to construct an scp command. But this doesn't seem very portable/practical to me. It appears some people have already written something like that: here and there.
The right way is (not only in my opinion) to:
have everything under some kind of VCS like Git, Subversion or Mercurial or whatever floats your boat
write your code in a local clone/checkout and test the hell out of it on a local server
commit only working code
push milestones to a staging server used by you and your clients to test everything, this part can be automated via a post-commit hook or something like that
deploy only validated changes on your production server.
All the aforementioned Version Control Systems can be used directly from Vim's command line with :!git commit or :!svn update… If you need more abstraction, Fugitive (Git-only) or VCSCommand (multi-VCS, my choice) are here to help.
On your loss of productivity due to uploading files: I think it's very normal because you essentially perform very different tasks with very different neurological needs. This speed bump can also be experienced when previewing a layout change in your browser, looking up a color in Photoshop or any other similar task. I don't know of a way to pilot Photoshop, Chrome's dev tools or Outlook from within Vim and I don't think such a gizmo could reallistically exist so you will probably have to bear with it.
You can try git-ftp - a git based command line ftp client. Then you can manage your project as a Git repository, and git-ftp will only upload the files marked with Git - and only if they have changed.
The downside is that you are going to have to learn Git - and that's a bit overkill for what you need.
The upside is that you are going to learn and use Git.
I have since stumbled upon a Vim plugin which works with Transmit (which I happen to use as my main FTP client) and allows me to upload the current file to the server with a simple keymap (Ctrl+U) as I edit.
This strikes a nice balance between being a very simple solution, and one that does enough of what I need to improve my productivity significantly.
Any more suggestions are still welcome!

Project update via TextMate (like Espresso)

I am thoroughly in love with TextMate. I program everything in it, including ASP.NET for my daily job. However, I have a license for Espresso, and I was looking at it recently and discovered that there is a "Publish" section that I knew about before, but I didn't know that it could compare my FTP directory with my local directory and publish only the changed files.
Over the past week I've been finding myself using Espresso just for that functionality. However, I was hoping there was a way to get this functionality inside TextMate. I know that you could use an AppleScript script with Cyberduck (my FTP client) to upload a file when it changes, but I have never got that working and it also doesn't include the ability to merge files like Espresso does.
Am I plumb out of luck? Am I stuck using two different programs for the forseeable future?
I haven't tried it, but you should be able to set up a simple rsync command in a bundle in TextMate that will use environment variables from your project to synchronise.
See Using rsync to enable the project drawer in TextMate while working on a remote server for an example.

Web Development Tools Question - Automatic File Upload

This should a quick question for some easy rep.
I'm doing some PHP Website development, decided to check out and play around with jQuery as well. I don't want to install and manage a local PHP server/service, but I would like a quick one click method for automatically uploading the PHP file I'm working on to my hosting service so I can test it live.
I'm looking into some different editors like Komodo Edit, Notepad++ but I'm wondering what tool has the ability to one click FTP for me?
Edit after a few posts came in:
Well Shoot, Ultra Edit costs around $100, and Aptana allows you to upload to their "Cloud", but you have to purchase the cloud space. I already have my own server. I'll have look into BlueFish a bit more....Thanks for the help guys.
I'm thinking I might try using Notepad++ and just write a batch file to run windows built in FTP, make a connection and copy all the files in a folder in auto-overwrite mode. Seem feasible?
I have a setup that I use FileZilla as the FTP, and NotePad++ as my text editor.
Within FileZilla, I set NotePad++ as the default text editor, and when I hit Ctrl-S within the file I am working on at that time, it automatically uploads those changes to the server.
You will be able to edit the preferences within FileZilla (http://filezilla-project.org) to set your default text editor, this is something you should be able to do with any FTP program.
Check out this post for more information: http://linhost.info/2008/01/notepad-and-filezilla-tip/
UEStudio has integrated (S)FTP, SVN, etc, plus the ability to open a file over FTP - of course, it actually just downloads to a temp file, but each time you press save, it uploads it to the server again.
I'm pretty much obliged to point out just now that you might want to reconsider your decision to avoid a local development environment. Using XAMPP, it's ridiculously easy to set up a local web server. There are a multitude of benefits to this, far too many to list, even.
The Aptana IDE can do one-click upload via FTP and also synchronize all files between your local environment and remote server (based on timestamps) with one click as well.
Bluefish can edit the file directly on the FTP server. I'm not sure if the Win32 version can do that though.
i use e-texteditor. It's some kind of textmate clone, only is better :P
I have used sublime text with sftp pluggin.
sublime3 and
sftp pluggin
You only need to config sftp file on root folder.
Works quite good.
Regards
Most advanced editors/IDE's like Zend Studio allow adding FTP servers and editing files directly. Once modified, pressing Ctrl+S would update the file on server.

Resources