jEdit SSH Console Plugin

Alan Ezust, alan dot ezust at gmail dot com

$Date: 2007-11-26 11:07:53 -0800 (Mon, 26 Nov 2007) $

This plugin is designed to allow you to easily compile files you are editing remotely via sftp:// and parse the errors for ErrorList. It has no user interface of its own, because it is an extension of three other plugins: Console, FTP, and ErrorList, and uses a docked jEdit File System Browser for navigation.

Console provides jEdit with a dockable command line interface to the System Shell and the BeanShell, and an open interface for adding new shells. SshConsole adds a jEdit Shell Service to Console called ssh.

Console parses the output of the commands through its own error parsers which are configurable from Plugin Options - Console - Error Parsers. When Console adds detected errors to the ErrorList dockable, you can click on the error, and jEdit will open the remote file for you if necessary, and position your caret at the error location.

The FTP plugin defines a virtual file system (VFS) called "sftp://", which allows the user to make secure sftp:// connections to remote hosts, and browse their file systems using jEdit's File System Browser, also known as FSB or VFSBrowser. At any time, the user can select, and then manipulate selected files from the FSB or jEdit. Since the FTP plugin handles prompting and remembering username/passwords, the SshConsole plugin assumes you want to ssh into the same host using the same port and creds as the most recent sftp:// connection in that View's FSB (or its currently editing buffer, if it is open to a file on a remote host via sftp).

Instructions for use:

Initially, the SshConsole does not know where to connect. You will see a prompt like this:

[no sftp:// connections?] >

At this point, any commands you type will be ignored. To tell the plugin to connect somewhere, you need to do one of these things:

  1. Navigate to a remote file via a docked File System Browser
  2. Edit a remote file in the current View's EditPane.

Here are instructions for first-time users:

  1. Plugins - SshConsole - Show SshConsole [1]
  2. Dock an FSB: Utilities - File System Browser . I suggest docking it on your left.
  3. With FSB: navigate to a remote host by entering a path that begins with sftp://.
  4. If this is your first time connecting, Enter your user/password/key/passphrase there.
  5. After you're connected, if you plan to connect often to this host, add it as a bookmark in the FSB.
  6. With FSB: click on (or open) the remote file that you want to compile.
  7. Enter commands in the ssh console. Initially, it will connect and show you the message of the day.
  8. Click on folders or files in the FSB. Notice the remote directory changes.
  9. Compile something with errors in it.
  10. Look at the ErrorList dockable. Click on an error in the dockable.

If later, you use the FSB to connect to a different remote sftp host, then the next time you use the SshConsole, it should logout of the old ssh session, create a new shell connection to the same host you just logged into via sftp, and send your shell commands there.

[1] Alternately, you can use Plugins - Console - Shells - Ssh, or open a Console and select ssh from the Shells combobox.

Job Control

Sending Ctrl-D (EOF), or Ctrl-Z (DETACH), work the way you would expect them to on a unix shell. To send a Ctrl-C, click on the "X" button in the Console pane (Ctrl-C is still a "copy to clipboard" shortcut). Other control keys typed during the execution of your program are not sent to the remote host. Let me know if you need one of them to be.

Built-in Commands

The following built-in commands which work in the System shell also work in the ssh shell:

Troubleshooting

Sometimes an ssh connection will timeout while you are using the SshConsole. If this happens, you will see an IOException in your activity log when you attempt to execute the next command. At this point, the console should automatically close its existing connection and open a new one when you enter the next command.

It may be necessary to click again on a remote file in the FSB, to remind the SshConsole where to connect.

If for some reason, after a timeout, your SshConsole is non-responsive, you can explicitly close all open connections from the Plugins - SshConsole - Close Connections menu action. This has the effect of restarting the plugin from scratch, so again, you will need to navigate to a remote file via the FSB so that SshConsole knows where to send your commands.

Future Ideas

These are things I'd like to have in this plugin at some point. Volunteers?

Enjoy! This is free software, released under the GPL V2. Feel free to contribute to it (or other plugins) too, by joining the jedit-devel@lists.sourceforge.net mailing list and submitting patches or suggestions.


History