Here's what I'd like to do: On my webserver, I'll edit my .bash_profile to include and alias for 'mate' to a shell script. The shell script will do the following: 1. secure copy the argument file to my local tmp folder 2. open the the local tmp file with 'mate -w' 3. once I finish editing the file in TextMate and close it, secure copy the new file to replace the file on the webserver
The problem is, I don't know anything about shell scripting. :-) But I'm wondering if anyone else already has something like that or would be willing to help write one.
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
Thanks, Simon
P.S.-I saw the copy to tmp folder idea in this useful view safari source applescript: http://comox.textdrive.com/pipermail/textmate/2005-September/005727.html
On Jan 9, 2006, at 11:39 PM, Simon Dorfman wrote:
Here's what I'd like to do: On my webserver, I'll edit my .bash_profile to include and alias for 'mate' to a shell script. The shell script will do the following:
- secure copy the argument file to my local tmp folder
- open the the local tmp file with 'mate -w'
- once I finish editing the file in TextMate and close it, secure
copy the new file to replace the file on the webserver
Interesting idea. The main issues I can see would be for the bash script to somehow know that TextMate had finished editing the file, and for the script to somehow send the file to your local system for the editing... The rest would be relatively easy to do in bash.
....after looking at the help on the mate command it looks like something like this would be very possible if the hurdle of getting the file to and from the local system. The mate command can wait until TextMate is finished with a file before continuing. This would make it trivial for the bash script to them simply continue when the file is finished with.
I'm a bit busy right now but if you want to wait a few days I might have time this weekend to write something but I'm not sure I know enough to get around the local system versus remote system thing...
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
Well Transmit always works and is what I use most of the time.
Jamie
_______________________________________________________________________ Email: jamie@methnen.com Homepage: http://www.methnen.com
"And I always go to pieces. And I have it in my mind, that the sky is tall and heavy, when I could be brave." -Karen Peris (Brave)
"I want to find where the maid in the street is pouring her wine, I heard she takes you in and gives you the words you need said. If you'll be her brother, she'll kiss you like a sister. She'll even be your mother, for now." -Matt Slocum (Sister, Mother)
"And we are drowned." -Annie Dillard (Tickets For a Prayer Wheel) _______________________________________________________________________
On 1/10/06 1:53 AM, "Methnen (AKA Jamie)" jamie@methnen.com wrote:
I'm a bit busy right now but if you want to wait a few days I might have time this weekend to write something but I'm not sure I know enough to get around the local system versus remote system thing...
Excellent! I look forward to seeing your script. Thanks!
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
Well Transmit always works and is what I use most of the time.
Yeah, I usually use Interarchy, but I would be handy to have this feature for when I'm already at the command line and need to make a change.
On Jan 9, 2006, at 11:39 PM, Simon Dorfman wrote:
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
If it's a web site you want to edit, you can enable a remote directory for WebDAV, then mount it with the Finder. You can then open any web site file as if it were local.
Another approach that I've seen in other programs is an inverse of what you suggest. Instead of the remote site pushing a file to the client, the client (i.e. the text editor) pulls the file from the server using SFTP. Although this doesn't allow a seamless "mate" command from the remote server's shell, it works with existing, well- known protocols and should be more reliable than a custom script.
Other text editors, such as jEdit and BBEdit, already support SFTP, so hopefully TextMate will also support it in the near future.
Trevor
On Jan 10, 2006, at 3:26 AM, Trevor Harmon wrote:
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
If it's a web site you want to edit, you can enable a remote directory for WebDAV, then mount it with the Finder. You can then open any web site file as if it were local.
This is what I've been doing for (most) remote editing; it's not a complete alternative to SFTP/SCP, but it works fine when it works.
My problem with it is similar to the problems people have editing files over SMB: TM is very slow to edit files on my DAV mount and it sometimes will wagon-wheel itself into oblivion.
Just another data point.
Cheers, Kendall Clark -- You're part of the human race All of the stars and the outer space Part of the system again
On 10 Jan 2006, at 08:39, Simon Dorfman wrote:
Here's what I'd like to do: On my webserver, I'll edit my .bash_profile to include and alias for 'mate' to a shell script. The shell script will do the following:
- secure copy the argument file to my local tmp folder
- open the the local tmp file with 'mate -w'
- once I finish editing the file in TextMate and close it, secure
copy the new file to replace the file on the webserver
The blog entry at <http://chucker.mystfans.com/2004/11/23/remotely- using-see-subethaedit-cli-through-ssh.entry> describes how to use SubEthaEdit's commandline 'see' tool to do something very similar. It shouldn't be easy to adapt this to TextMate's 'mate' tool. (I haven't tried yet... YMMV.)
Regards,
Denis Defreyne
-- mail: amonre@amonre.org web: http://www.amonre.org/
On Tue, 10 Jan 2006 07:39:35 -0000, Simon Dorfman emaillists@simondorfman.com wrote:
Here's what I'd like to do: On my webserver, I'll edit my .bash_profile to include and alias for 'mate' to a shell script. The shell script will do the following:
- secure copy the argument file to my local tmp folder
- open the the local tmp file with 'mate -w'
- once I finish editing the file in TextMate and close it, secure copy
the new file to replace the file on the webserver
No scripts needed - Cyberduck does that. It supports SSH and TextMate. http://cyberduck.ch/
On 10/01/06, Simon Dorfman emaillists@simondorfman.com wrote:
On my webserver, I'll edit my .bash_profile to include and alias for 'mate' to a shell script. The shell script will do the following:
- secure copy the argument file to my local tmp folder
Watch out, if you want to edit foo/index.html and bar/index.html simultaniously
- open the the local tmp file with 'mate -w'
Should be possible with a folderaction. For someone that knows applescript, that is.
- once I finish editing the file in TextMate and close it, secure copy the
new file to replace the file on the webserver
No folderaction for this, so the textmate save routine would need to trigger that.
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
Try Webdav, if possible. For my situation, it is not :-(
Bye, Martin
Believe it or not, this works:
ssh mythtv@dell "cat ~/test_file" | mate | ssh mythtv@dell "cat
~/test_file"
So I created this script for you. I put this in /usr/local/bin/rmate (r for remote). Be sure and chmod a+x /usr/local/bin/rmate:
#!/bin/sh
HOST='most.often.used.host' USER='most.often.used.username' FILE=''
if [ $# == 0 ]; then echo "Usage: $0 [-h host] [-u user] [-f] file" exit 1 fi
while [ "$1" != "" ]; do
case $1 in -h) HOST=$2 shift 2 ;; -u) USER=$2 shift 2 ;; -f) FILE=$2 shift 2 ;; *) FILE=$1 shift ;; esac done
TMPNAME=$FILE.`date +%Y%m%d%H%M%S` ssh $USER@$HOST "cp -a $FILE $TMPNAME if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." exit 1 fi" ssh $USER@$HOST "ls -lh $FILE*" echo "Backup file is $TMPNAME" ssh $USER@$HOST "cat $TMPNAME" | \ mate | \ ssh $USER@$HOST "cat >$FILE" if [ $? -ne 0 ]; then echo "The ssh failed to $HOST for $USER to edit $FILE" fi
Regards, JJ
On 10-Jan-2006, at 02:39, Simon Dorfman wrote:
Here's what I'd like to do: On my webserver, I'll edit my .bash_profile to include and alias for 'mate' to a shell script. The shell script will do the following:
- secure copy the argument file to my local tmp folder
- open the the local tmp file with 'mate -w'
- once I finish editing the file in TextMate and close it, secure
copy the new file to replace the file on the webserver
The problem is, I don't know anything about shell scripting. :-) But I'm wondering if anyone else already has something like that or would be willing to help write one.
Any other ideas for accomplishing the same goal (edit remote files with TextMate) are also welcome.
Thanks, Simon
P.S.-I saw the copy to tmp folder idea in this useful view safari source applescript: http://comox.textdrive.com/pipermail/textmate/2005-September/ 005727.html
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
--- Help everyone. If you can't do that, then at least be nice.
On 1/10/06 3:20 PM, "John Johnson" johnatl@mac.com wrote:
Believe it or not, this works:
ssh mythtv@dell "cat ~/test_file" | mate | ssh mythtv@dell "cat
~/test_file"
So I created this script for you. I put this in /usr/local/bin/rmate (r for remote). Be sure and chmod a+x /usr/local/bin/rmate:
#!/bin/sh
HOST='most.often.used.host' USER='most.often.used.username' FILE=''
<snip>
If I understand it correctly, this script isn't very useful to me. The problem is that I often ssh to my webserver from public wi-fi access points which means I can't enter a hostname where my webserver can ssh back to my laptop. Is there a way for the script to use the existing ssh connection to copy the file?
Simon
P.S.- I did try running your script from my laptop for the heck of it and got this error: cp: illegal option -- a I double checked the man pages for cp and saw that -a wasn't an option. So I deleted the "-a " from your script and then it worked.
Cyberduck FTP can connect to an sftp server and open files in a text editor (textmates one of the options). When you save the file in textmate, it then automatically uploads back to the server.
Jeremy
On 17 Jan 2006, at 10:46, Simon Dorfman wrote:
On 1/10/06 3:20 PM, "John Johnson" johnatl@mac.com wrote:
Believe it or not, this works:
ssh mythtv@dell "cat ~/test_file" | mate | ssh mythtv@dell "cat
~/test_file"
So I created this script for you. I put this in /usr/local/bin/rmate (r for remote). Be sure and chmod a+x /usr/local/bin/rmate:
#!/bin/sh
HOST='most.often.used.host' USER='most.often.used.username' FILE=''
<snip>
If I understand it correctly, this script isn't very useful to me. The problem is that I often ssh to my webserver from public wi-fi access points which means I can't enter a hostname where my webserver can ssh back to my laptop. Is there a way for the script to use the existing ssh connection to copy the file?
Simon
P.S.- I did try running your script from my laptop for the heck of it and got this error: cp: illegal option -- a I double checked the man pages for cp and saw that -a wasn't an option. So I deleted the "-a " from your script and then it worked.
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
--- Jeremy Wilkins Ibex Internet Ltd
Parkside Business Park Parkside Rd. Kendal Cumbria LA9 7EN
Tel: 0845 226 8342 Fax: 08718 729374
On 1/17/06, Jeremy Wilkins jeremy@ibexinternet.co.uk wrote:
Cyberduck FTP can connect to an sftp server and open files in a text editor (textmates one of the options). When you save the file in textmate, it then automatically uploads back to the server.
Cyberduck is a very nice client. But you should use version 2.5.2 not the current 2.5.3 because the new version tends to crash a lot.
http://cyberduck.ch/Cyberduck-2.5.2.dmg
Thomas
On 1/17/06 4:57 AM, "Jeremy Wilkins" jeremy@ibexinternet.co.uk wrote:
Cyberduck FTP can connect to an sftp server and open files in a text editor (textmates one of the options). When you save the file in textmate, it then automatically uploads back to the server.
My FTP client of choice (Interarchy) can do that also. But sometimes I'm at a command line, logged in via SSH and I just wish I could type "mate" to edit a file instead of "nano".
Ok, theres a $SSH_CONNECTION variable which gets set, that includes both client and server IP addresses.
You should be able to pull the client IP out of that with sed, then a script like
scp $1 <clientip>:/tmp/$1 ssh <clientip> mate -w /tmp/$1 scp <clientip>:/tmp/$1 $1
Jeremy
On 17 Jan 2006, at 11:08, Simon Dorfman wrote:
On 1/17/06 4:57 AM, "Jeremy Wilkins" jeremy@ibexinternet.co.uk wrote:
Cyberduck FTP can connect to an sftp server and open files in a text editor (textmates one of the options). When you save the file in textmate, it then automatically uploads back to the server.
My FTP client of choice (Interarchy) can do that also. But sometimes I'm at a command line, logged in via SSH and I just wish I could type "mate" to edit a file instead of "nano".
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
--- Jeremy Wilkins Ibex Internet Ltd
Parkside Business Park Parkside Rd. Kendal Cumbria LA9 7EN
Tel: 0845 226 8342 Fax: 08718 729374
On 17/01/2006, at 11:46, Simon Dorfman wrote:
P.S.- I did try running your script from my laptop for the heck of it and got this error: cp: illegal option -- a I double checked the man pages for cp and saw that -a wasn't an option. So I deleted the "-a " from your script and then it worked.
Unfortunately the BSD versions of the common commands, often aren't nearly as powerful as the GNU versions (for which -a works, and causes it to copy along all auxiliary information such as owner, protection, dates).
-- Sune.
John Johnson wrote:
Believe it or not, this works:
ssh mythtv@dell "cat ~/test_file" | mate | ssh mythtv@dell "cat
~/test_file"
From this, I tried doing
<file ssh stibbons mate >newfile
(the syntax is correct, though a bit weird), but I get “mate: failed to establish connection with TextMate”. Sounds like a reasonable security measure on Apples side not to allow programs started from remote to connect to those running locally, but ... is there a way to do it anyway? :-) (I know I could set up a local server over named sockets or tcp that would invoke mate, but that seems a little over the top.)
Regards, Christopher
On 14/2/2006, at 9:54, Christopher Creutzig wrote:
[...] I get “mate: failed to establish connection with TextMate”. Sounds like a reasonable security measure on Apples side not to allow programs started from remote to connect to those running locally, but ... is there a way to do it anyway? :-)
You can run mate successfully by going through osascript (the connection restriction is enforced by Distributed Objects, I don't really think it's intentional), e.g.:
ssh simplit.com "osascript -e 'tell app "Terminal" to do shell script "mate"'"
But to have it edit stdin (from ssh's POV), it gets more complex, e.g.:
<file ssh simplit.com "cat >/tmp/dummy.txt; osascript -e 'tell app "Terminal" to do shell script "mate </tmp/dummy.txt"'" >newfile
Allan Odgaard wrote:
You can run mate successfully by going through osascript (the
Thanks, that works fine. For everyone interested, I include the rmate script I now have on my linux machine. I'm actually using a named temp file to make use of the suffix recognition in TM. To automatically get back to the mac you have been connecting from (certainly useful for the root server you rented, I'll do that there), set
HOST=${SSH_CLIENT%% *}
instead of some other default. (As you can see, I started from John's script and just tweaked the commands to work the other way round, hence the subject change.) With four scp/ssh invocations, I strongly recommend using ssh keys and ssh-agent or something like that, for typing your password four times for a single edit is hardly improving security ...
----------------------------------------------------------------------- #!/bin/sh
HOST='your.mac.machine' USER='myself' FILE=''
if [ $# == 0 ]; then echo "Usage: $0 [-h host] [-u user] [-f] file" exit 1 fi
while [ "$1" != "" ]; do
case $1 in -h) HOST=$2 shift 2 ;; -u) USER=$2 shift 2 ;; -f) shift 2 ;; -f) FILE=$2 shift 2 ;; *) FILE=$1 shift ;; esac done
TMPNAME=`date +%Y%m%d%H%M%S`.$FILE
scp -p $FILE $USER@$HOST:/tmp/$TMPNAME && \ ssh $USER@$HOST "osascript -e \ 'tell app "Terminal" to do \ shell script "mate -w /tmp/$TMPNAME"'"
if [ $? -eq 0 ]; then scp -p $USER@$HOST:/tmp/$TMPNAME $FILE fi ssh $USER@$HOST "rm /tmp/$TMPNAME"
-----------------------------------------------------------------------
regards, Christopher