I'm new to Sublime Text 2 and there's something I haven't figured out yet, how can I run a bash command over SSH ?
For example, to view the Apache error log on my dev server, I'd like to be able to run :
ssh [email protected] "tail -10 /var/log/httpd-error-user.log"
Instead of having to open a terminal, I'd like to run this from within the editor with a keyboad shortcut.
I've read about build systems, but I'm not sure it's the way to go, also it seems to allow only one command.
I'll answer my own question. You can easily create a build pointing to any script, so all I had to do was create myscript.sh
containing :
#!/bin/bash
ssh [email protected] "tail -10 /var/log/httpd-error-user.log"
And then create a new Build System in ST2 to call it :
{
"cmd": ["./myscript.sh"]
}
Note : In this example (i'm on Linux), myscript.sh
is located in /home/mike/.config/sublime-text-2/Packages/User/
If You are on a windows machine, You could try this:
plink
from this package.PATH
variable with Putty install directory.Create a Build System in Sublime
{
"cmd": ["plink", "-pw", "<password>", "<userid>@<remotehost>", "./your-script.sh"]
}
I use it for remote make
, works quite good.
Note that your password is plain text here. I know it's no good ;]. This is just an example. To fix it keybased login could be used. Google PuttyGen and autologin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With