Giter VIP home page Giter VIP logo

rsub's Introduction

rsub

Description

Rsub is an implementation of TextMate 2's 'rmate' feature for Sublime Text 2, allowing files to be edited on a remote server using SSH port forwarding / tunnelling.

Included in this repository are two implementations of the 'rmate' command, the original written in Ruby, and another version written using bash scripting. You will need to choose and copy one of these up to your server, usually with scp, sftp, or plain FTP. See the README file inside rmate-bash for more detail.

Installation

You can install this plugin using sublime package control. It will keep all your plugins up to date. http://wbond.net/sublime_packages/package_control


OR

You can also clone this repository into the Sublime Text 2 'Packages' directory, but you will have to update it manually.

On Mac OS X, this is located at ~/Library/Application Support/Sublime Text 2/Packages.

Run the following commands in Terminal, then restart Sublime Text 2:

cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
git clone git://github.com/henrikpersson/rsub.git rsub

SSH tunneling

Due to security reasons, rsub is only listening for local connections.

Simply put this in your ~/.ssh/config to enable remote forwarding for your server(s):

Host example.com
    RemoteForward 52698 127.0.0.1:52698

Usage

Once you have rmate installed on your remote server (installation instructions can be found here), rsub installed on your local machine and an ssh tunnel open, execute the following command on your remote server to edit files in SublimeText:

rmate <filename>

More information on command line options can be found in the rmate repository.

rsub's People

Contributors

andrewimeson avatar arielscarpinelli avatar codeman38 avatar drarok avatar drevicko avatar franciscolourenco avatar generalov avatar henrikpersson avatar infernozeus avatar jfromaniello avatar jrnewell avatar kes777 avatar mattiashosio avatar mpak avatar randy3k avatar stefanom avatar taylorludwig avatar tornewuff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rsub's Issues

Trouble with large css file

When I open a large css file (over 2900 lines) using the ruby version of rsub, and then save it, a diff of the files shows that every line in the file has been modified, even if I haven't changed a thing in the file.

This only occurs with large files. Other css files or other type of files do not have this issue.

not bringing subllime text 3 on linux

Sublime text 3 has window class subl3.Subl3. Changing it in wmctrl command in source fixes this. I'm not sure though, does this extension support subl2 still?

Possible tip for Readme

If you add:
alias subl="rmate $1"
to your remote ~/.bash_profile then typing subl foo.txt in an ssh shell will open foo.txt locally using Sublime Text. Of course if Sublime Text is also installed remotely then this will override the normal subl command but it might be worth noting this in the readme for people who only have Sublime installed locally.

Listen to Multiple Ports

Hello, I sometimes have multiple ssh sessions open at the same time. I have the forwarding port different for each server I'm connected to. To switch servers for rsub, I have to change the port every time I want to use rsub on a different server.

Could a feature be added to where I can add a list of ports rsub is listening to? Or is it possible to do this already?

Thanks!

doesn't work on Linux(Arch linux x86_64)

Looks like its importing osx specific modules from python

however commenting the problematic line does work-around the problem.

Traceback (most recent call last):
File "./sublime_plugin.py", line 62, in reload_plugin
File "./rsub.py", line 8, in
from ScriptingBridge import SBApplication

ImportError: No module named ScriptingBridge

option '--host auto' has no effect

If you look into your code:

58:
host = localhost
....
88:
if [[ "$host" = "auto" && "$SSH_CONNECTION" != "" ]]; then
    echo "HERE"
    host=${SSH_CONNECTION%% *}
fi

You can notice that at line 88 $host is always localhost. It seems this code must be after command line option processing

Option to open rsub files in a separate window

If there is no open window when an incoming connection is received, rsub already creates a one.
This is a request for an option which makes rsub open files always in a separate window.
Ideally rsub would assign a window to itself, and open all files in that window.

File are truncated

When working with long files, they are truncated at different lengths when saved.

Edit: Only occurs with the bash script, ruby seems fine

Allow to configure directory for remote files

When using wakatime plugin we can create developers time which he spent to this or that project.

Thus, when switching to different project in sublime: Project->Switch project.... We should open files from different directory to count time as ProjectX instead of ProjectY
This is done in waka time by configuring that /home/user/project/X belongs to ProjectX project and /home/user/project/Y to ProjectY

Allow to put some configurations into xxx.sublime-project configuration file so rsub will open remote files (save them temporary) under /user/home/project/X/remote directory:

 rsub:  {
     tmpdir: /user/home/project/X/remote
 }

Not working if server also running Sublime

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.

Unable to open root files

I have changed rsub default port and it works great. I'm on a debian machine.
But when I try to change root priveligied files with sudo or in root user it doesn't work.
It says:
/usr/local/bin/rsub: connect: Connection refused
/usr/local/bin/rsub: line 327: /dev/tcp/localhost/52698: Connection refused
Unable to connect to TextMate on localhost:52698

It appears that on root user rsub tries to use the default port instead of the one that i'm using.
Hope that someone can give me some feedback.
Thanks

Error with bash rmate

This is the output i get on the console when trying to rmate

[rsub] New connection from ('127.0.0.1', 63362)

Exception happened during processing of request from ('127.0.0.1', 63362)
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 560, in process_request_thread
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 322, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py", line 617, in init
self.handle()
File "./rsub.py", line 118, in handle
File "./rsub.py", line 42, in parse_input
ValueError: invalid literal for int() with base 10: 'users'

implement fallback editor

I often work or remotely or direct.
And I switch my EDITOR env variable beetween 'rsub' and local editor.

Please implement 'RSUB_FALLBACK_EDITOR' which will contain editor (or command) to run when rsub port is not accessible.

This let just work and do not think about EDITOR env

add info to repo homepage on how to "shutdown"

Hi,

Thanks so much for this wonderful plug in!

I'm using rsub on a local machine running OSX 10.7 and a remote server running Ubuntu 12.04.5

One thing that I've noticed is that there is practically no information about how to "shutdown" rsub should you lose your connection with the server you are working on remotely (or some other reason). Of course, the better thing for me to do is to use this with something like tmux which would keep it running. However, recently I haven't been using it and naturally, after a while the pipe breaks. If this happens, after you log back in to the remote server, rsub won't open the file, instead you just get something like this:

user@server: rsub yourfile.html
[]  

And you have to ctrl-c to get back to the shell.

Or, you'll get something like this:

/usr/local/bin/rsub: line 301: /dev/tcp/localhost/52698: Connection refused
Unable to connect to TextMate on localhost:52698

I've googled up and down about it (and of course restarted ST2), and surprisingly while there are tutorials on how to use rsub, no one mentions what to do if it stops working. There's a post on SO that recommends killing the process by searching using netstat:

sudo netstat -antpl -p  | grep 52698
sudo kill -9 xxxx

http://stackoverflow.com/questions/11818131/warning-remote-port-forwarding-failed-for-listen-port-52698

But this only works about half the time.

Any advice you have on this would be great.

Thanks again,

Benjamin

Windows support

I only see code to handle osx and linux platforms. Is windows supported now, or is it planned for the future?

Doesn't appear to work on OSX Mountain Lion.

[rsub] Server running on localhost:52698...
[rsub] New connection from ('127.0.0.1', 60955)
Traceback (most recent call last):
File "./rsub.py", line 77, in on_done
KeyError: 'display-name'

Installed via Package Control.

Nothing happens when no windows are open

A new window should be created when no window exist and always if open_files_in_new_window is set to true.
Sublime text should also be brought forwards and get focus.

Hostname with open file

I'm not sure if this is an rmate issue or something with rsub implementation but on some systems it seems the hostname:file is showing in Sublime but on others its just hostname.

What exactly determines this? I've tried to upgrade to a later version of ruby on the system that it doesn't work on and it didn't make a difference.

rsub doesn't bind IPv6

When connecting to IPv6 remote hosts, I get an error using rmate:
connect_to 127.0.0.1: unknown host (nodename nor servname provided, or not known)

If I change RemoteForward 127.0.0.1:52698 127.0.0.1:52698 to RemoteForward 127.0.0.1:52698 localhost:52698, I get this:
connect_to localhost port 52698: failed.

This is because rsub isn't binding tcp6 port 52698 on my local computer:

$ netstat -anl | grep 698
tcp4       0      0  127.0.0.1.52698        *.*                    LISTEN

A terrible workaround:
socat TCP6-LISTEN:52698,fork,bind=[::1] TCP4:127.0.0.1:52698

Is there a nice way to add IPv6 support to rsub?

/opt/bin/rsub: line 393: /dev/tcp/localhost/52698: Connection refused

Please help! =(

[~]> cat ~/.ssh/config
Host router
User me
HostName 192.168.1.1
Port 65000
RemoteForward 52698 localhost:52698
[~]> ssh router
ASUSWRT-Merlin RT-AC5300 384.8-2 Sat Dec 8 18:19:13 UTC 2018
me@RT-AC5300-EC70:/tmp/home/root# /opt/bin/rsub ~/test.txt

/opt/bin/rsub: connect: Connection refused
/opt/bin/rsub: line 393: /dev/tcp/localhost/52698: Connection refused
me@RT-AC5300-EC70:/tmp/home/root#

WTF!?

Tried to dump all iptables rules. No luck =(((

logger "Setting default filter policy"
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
logger "Flushing all rules"
#-F flushes all the chains. Chains can't be deleted unless they are empty
iptables -F
#-X Delets all the non-builtin chains in the table
iptables -X
#-Z Zero's the packet and byte counters in all chains
iptables -Z

rsub isn't installing properly

I'm having a bit of issues getting this to work. I don't have superuser privileges on my remote machine so I did ~/rsub instead of /usr/local/bin, but this didn't work. When I type rsub filename.py after ssh-ing into my remote machine, I get error "-bash: rsub: command not found". My .ssh/config has the remote forwarding lines added to it. Any idea what I've done wrong?

Empty lines at bottom of files are always removed

Whenever I open a file with rsub and save it, any empty lines are the bottom of the file are removed. I would prefer to remove these only by choice not automatically on save.

Edit: using the ruby version

nothing happens when creating new file

rmate [existing_file] opens as it should in both textmate2/3 for me
rmate[non_existing_file] produce no results at all. expected result open a new blank file in sublime (?) (Mountain Lion / Debian)

edit:
this was a problem with rmate not submitting any data at all when file was not existing, seems that sublime needs both size=0 and and empty string to open a blank document.. i don't know if this is specific for sublime and does not apply to textmate so i just forked the submodule and fixed it here https://github.com/m4rkus/rmate

problem solved ;)

Status of project?

Last commit in 2017, multiple issues and what not since then. Is this project still maintained?

rsub with multiple computers in the same server

I'm trying to use rsub with multiple computers on the same server, however, it only works for one. When I try to use it from other computers, files are opened in the first computer. I tried following the instructions in the Port Forwarding section of this blog. But couldn't solve it. Any suggestions?

Partial files

When I use rmate to open a file I often get a partial (the first few lines) file opened in the editor. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.