I find myself performing this REPL-like action quite often:
vim foo.sh
scp foo.sh host:/tmp/foo.sh
ssh host /tmp/foo.sh
# realizing it wasn't quite right
vim foo.sh
scp foo.sh host:/tmp/foo.sh
ssh host /tmp/foo.sh
# 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
make
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?
Step 1: Mount your remote host as a local folder using SSH-FUSE.
Step 2:
vim ssh-mount/foo.sh
Step 3: From a second terminal, or forking from vim, run
ssh host:.../foo.sh
Rinse and repeat.
Link: http://fuse.sourceforge.net/sshfs.html
You don't need to repeatedly
scp
to the server; let Vim handle that for you automatically!You can then run
ssh user@host
in a separate terminal, and runmake
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
.