Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I find myself performing this REPL-like action quite often:

scp host:/tmp/
ssh host /tmp/
# realizing it wasn't quite right
scp host:/tmp/
ssh host /tmp/
# repeat many times

I was about to plow away at writing a shell script to make this simpler, but was wondering if someone smarter than me solved this problem more elegantly.

What's your solution? Besides emacs :)

EDIT: Why not just edit my file on the remote host? Simple, the hosts receiving my scripts won't always have a dev environment set up, so in this case host might not have all of my vim customizations; sometimes it'll be C code instead of a shell script, which means my workflow looks like:

vim foo.c
scp foo host:/tmp/foo
ssh host /tmp/foo
# repeat

That's why. I guess I want something with an interface like:

edit_loop foo.c --make --copy-and-run=host:/tmp/foo

What do you think?

share|improve this question
ssh remotehost bash <
share|improve this answer

Step 1: Mount your remote host as a local folder using SSH-FUSE.

Step 2: vim ssh-mount/

Step 3: From a second terminal, or forking from vim, run ssh host:.../

Rinse and repeat.


share|improve this answer
In fact, if you can run make with local tools, then you can use SSH-FUSE as in the C example, keep the source remote-mounted, and use local build tools. – mpbloch Jun 21 '10 at 14:42

You don't need to repeatedly scp to the server; let Vim handle that for you automatically!

vim scp://user@host/path/to/file

You can then run ssh user@host in a separate terminal, and run make or /path/to/file there.

If you need a build environment that is not available on the server, you should instead check out the previous answer about sshfs.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.