You can use rsub and rmate to edit remote files in your local Sublime Text over ssh.
You need to
Host SERVERNAME
RemoteForward 52698 127.0.0.1:52698
- connect to your server with
ssh
- install the
rsub
script on the remote machine:
sudo wget -O /usr/local/bin/rsub https://raw.github.com/aurora/rmate/master/rmate
sudo chmod +x /usr/local/bin/rsub
Then you can do rsub file
in the ssh session and it will open file
in your local ST editor.
Works with ST2/ST3 and you can also sudo rsub file
!
I think it'd be most useful if I took this a piece at a time. The general problem is: who is the key press intended for? The terminal, or the program running inside the terminal?
As an example, "screen", which is kindof a terminal, uses Ctrl+A as a prefix for its commands, to distinguish them from things going to the running program itself. (And provides a way to send Ctrl+A.)
gnome-terminal
has several keys that it captures to do various things, including some of the ones you ask about.
Also keep in mind that a terminal's "highlighting" is separate from the terminal's cursor position. Some terminals have no ability to highlight at all.
Now, taking this key combinations at a time:
left+right arrows to move left+right
ctrl+arrow to move an entire word
home/end to move to start/end of line
Move what left and right? Bash can be configured to do this, and typically is by default. Typically, these move the cursor position.
ctrl+c/ctrl+v to copy/paste
First: does copy/paste even make sense? If you're at a VT, you don't really have a clipboard, especially if X isn't running.
Some terminals can copy text in the output, and some will also "paste" by simulating you typing the contents of the clipboard. Ctrl+Shift+V, for example, is paste in gnome-terminal
, which may help. (And Ctrl+Shift+C is copy.) As discussed earlier, the big problem with Ctrl+C and Ctrl+V is they overlap with common terminal/program commands. (Ctrl+C is send interrupt (SIGINT) and Ctrl+V is verbatim.)
Some terminals also support two modes of copying data: a more normal "just copy", and what's known as "block select" or "block copy". (Hold Ctrl, and then drag while in gnome-terminal
for example.)
Additionally, xsel -b
can be used to pipe clipboard contents around. Depends on the exact situtation whether xsel
or the terminal's version of paste is more useful. See man xsel
.
shift+arrow to highlight text
shift+ctrl+arrow to highlight an entire word
Your terminal's highlight (if it has this capability) is separate from cursor position. Again, lack of available key combos is probably a factor. Keep in mind a highlight has two positions: either the start and end, or the upper left and lower right corners. How do you manage both?
Finally, note that many GUI terminals, double-clicking a word will highlight it. (And in X, copy to the primary selection.)
screen
, as an example, has keys to switch into a mode for moving around the buffer (previous output) and copy/pasting.
I think if you make adequate use of xsel
and the primary selection, you will find clipboard operations are both rare enough and complex enough to merit using the mouse.
Best Answer
Have a look at the Sanos editor:
http://www.jbox.dk/sanos/editor.htm
Only a 28k binary can do what all those other editors try to -- and fail.
It does exactly what the OP asked for:
Shift+arrows to highlight text
Ctrl-X,C,V for cut/copy/paste
You can also have several open files simultaneously, and "pipe" commands into it. For example, press Ctrl-P and at the prompt enter:
cat yourfile
and it will insert yourfile at the position of the cursor. This way the full power of the bash commands are at your disposal ( use grep to get only specific parts of the file inserted ).