henrikpersson / rsub

Use rmate with Sublime Text.
458 stars 70 forks source link

Not working if server also running Sublime #67

Closed jlucier closed 6 years ago

jlucier commented 7 years ago

I frequently use rsub to edit files on my desktop while I'm away from home. However, if I leave Sublime (with rsub installed) running on my desktop and then try to rsub the file to my laptop, it opens the file in Sublime on my desktop and not my laptop. Not sure there is a great way around it, but I thought I'd put this out there.

KES777 commented 7 years ago

I put next lines into my ~/.bash_aliases to control how to open files:

if [ -z "$SSH_CLIENT" ]; then               
        export EDITOR="subl"
else
        export EDITOR="rsub --port 52697"
        export RMATE_PORT="52697"
fi

Here I check if this terminal is remote session or not. If not the EDITOER = subl else force to use rsub. As you can see here I force rsub use not standart port 52697

So also on your laptop you should bridge this port when ssh`ing to your server:

host    serverf            #f stands for `forward`
        user YourUser
        hostname Your.domain.for.server
        PreferredAuthentications publickey
        port 22
        identityfile /path/to/key
        RemoteForward 52697 127.0.0.1:52698   ## <<<< THE MAGIC

Now on your laptop you may do: ssh serverf