aurora / rmate

Remote TextMate 2 implemented as shell script
GNU General Public License v3.0
887 stars 123 forks source link

Can't rmate when remote machine running textmate #50

Closed hardwhack closed 8 years ago

hardwhack commented 8 years ago

I have been trying to get rmate working on remote machines (Mac Pros which also have textmate2 installed). rmate works fine from my macbook when sshing to linux machines but only works intermittently when sshing to mac pros. It took a while but I realized that when I run the rmate command on the remote mac pros, the text file is opened on the remote machine using textmate2! If I quit textmate on the remote machine, then rmate works fine.

My understanding of port forwarding is somewhat rudimentary. When textmate is not running on the remote machine, the port 52698 listeners are (using sudo lsof -P | grep 52698) sshd 7671 pjkim 13u IPv4 0x398710fcbf7fdb45 0t0 TCP localhost:52698 (LISTEN)

If textmate is running, there are two listeners: sshd 7671 pjkim 13u IPv4 0x398710fcbf7fdb45 0t0 TCP localhost:52698 (LISTEN) TextMate 7748 anotheruser 17u IPv6 0x398710fcbb8197ad 0t0 TCP localhost:52698 (LISTEN)

When I run the rmate command, it preferentially is routed (is that the right word) to the local listener and opens textmate2.

I can probably do an ugly workaround by changing the port numbers but that would require a lot of number juggling. Is there an easier way?

hardwhack commented 8 years ago

Found a workaround for this issue that isn't too complicated. On my local machine, I changed port forwarding to use hostport 52699 instead of 52698. It still gets mapped back to 52698 on my local machine. I do this only for sshing to machines that can run textmate2, i.e. macs. This can be done by changing the ssh line to

ssh -R 52699:localhost:52698 hostmac

On the hostmac, you will need to have rmate use port 52699. I did this by adding the line alias rmate='rmate -p 52699' to my .bash_profile.

aurora commented 8 years ago

This is not an issue with rmate: with TCP you can only have one listener per port and IP address.