At YAPC::Europe this year they had a section called life hacks where you show other people things from your ~/bin
directory in the hope that someone else might find it interesting. I was too busy at the time to share mine, so I thought I'd post it here.
My all time killer script is the one that Tom Insam came up with after we discussed the problem for a while. Basically, we do all our work on a development server and we can ssh and samba mount the device. When I'm working locally on my laptop I can edit any file by typing "ec $filename"
and it loads in my local editor (a Carbonized Emacs.) I wanted the same thing when I'm sshed in to the development box.
So Tom came up with the idea of writing a script that starts another ssh session to the dev box and tails a file on the dev machine. The ec script on the dev machine writes to the end of the file instead of starting a process. The local end of the new ssh tunnel gets the filename and then spawns a local process to edit the file with my local editor over samba. Sweet! Completely transparent.
Of course it's more complicated than that. Whole YAML data structures get written to the file, so in theory at a later date I can extend the script to do something more useful. And I no longer run it as a shell script, I've got a CamelBones application written that runs the script and tails the output.
I know it's a simple idea, but the simple ideas are normally the best. It means I don't have to use a X11 forwarded editor from the dev server (eeek) nor do I have to have a seperate terminal for editing (running locally in the directory mounted via samba) and executing code (running remotely over ssh) on the dev server.
Huzzah.
Sounds like you just reinvented efs angie-ftp or tramp.
Or you can just go all the way.
Re:Can't emacs already do that?
2shortplanks on 2004-09-28T09:42:40
I've used tramp in the past. It's good, but loading stuff across ssh is just too slow because it sets up a new connection each time (and yes, I've tried fsh...still too slow.) Samba is *way* quicker. FTP suffers from the same problem.
I've got a mac, so I can't try linux kernel madness, but I doubt it's fast enough. For crazy lack of speed since the finder can mount an FTP server in the past I've tried to use Filesys::Virtual::SSH with POE::Component::Server::FTP to make a FTP/SSH bridge so that I could mount SSH. It works, but it was insanely slow.Re:Can't emacs already do that?
pudge on 2004-09-28T23:48:30
I use a thing called cenotaph that Matthias Neearcher wrote, and I ported to perl (it was initially a C++ server and perl client, now both ends in perl).
You execute the client on the remote machine, with "ceno $filename". It opens the file on the server, your local machine, in your editor. How to open in your local editor is a matter for you to figure out; it's designed out of the box to work with BBEdit (and the command line bbedit(1)). I use ceno all the time.