I've been trying to create an 'edit' command that will approximate me being able to edit a file directly on an sftp server without leaving lftp (a useful thing for web developers). Due to there not being parameter symbols in the lftp aliases its a bit convoluted and i wondered if anyone had a nicer solution.

So far i have a shell script in ~/.lftp called edit.sh which does this:

#!/bin/sh
tempid=$$
echo get $1 -o /tmp/$tempid$1 > ~/.lftp/editcommand
echo shell vim /tmp/$tempid$1 >> ~/.lftp/editcommand
echo put -E /tmp/$tempid$1 -o $1 >> ~/.lftp/editcommand

Then i put these aliases in ~/.lftp/rc:

alias edit ! ~/.lftp/edit.sh
alias vim source ~/.lftp/editcommand

Then connected to my sftp server i can type:

edit somefile.html
vim

Which lets me edit in place. I'd like to have done in one command. Any ideas?

Thanks

Tom



Reply via email to