Overview
The goal of this plugin is to allow users to execute external commands from gedit interface. This allow the user to do two things : either to pipe some content into a command and to exploit its output (for example, sed), or to simply launch some predefined command (for example, make).
Using Tools
Install the plugin. Menu: Tools -> External Tools. A dialog will appear and you can start adding tools. Every configured tools appear at the top of the Tools menu.
External Tools dialog
The name of the current tool can be edited directly using the list on the left side of the dialog.
Here is a short description of the editable properties for a given tool :
- Description: the description of current tool (this is what will be shown in the statusbar when hovering the related menu entry).
- Accelerator: the key binding associated to the current tool.
- Commands: the actual commands to be ran.
- Input: what content to give to the commands (as stdin)
- Output: what to do with the commands output
- Applicability: what documents can be affected by that tool ? (criteria are : saved or not, local or distant)
You can add and remove custom tools, and customize system-provided tools. You can revert latter ones to the upstream version in one click.
Available Environment Variables
- GEDIT_CURRENT_DOCUMENT_URI
- GEDIT_CURRENT_DOCUMENT_NAME
- GEDIT_CURRENT_DOCUMENT_SCHEME
- GEDIT_CURRENT_DOCUMENT_PATH
- GEDIT_CURRENT_DOCUMENT_DIR
- GEDIT_DOCUMENTS_URI
- GEDIT_DOCUMENTS_PATH
To be added:
- GEDIT_CURRENT_DOCUMENT_TYPE
Storage and hand-editing of tools
From gedit 2.17.1 on, System tools are stored in $XDG_DATA_DIRS/gedit-2/plugins/tools, and user ones are stored in $HOME/.gnome2/gedit/tools. Each tool consists on an executable script file (in bash, perl, python, ruby, etc.) containing a metadata section that resembles usual desktop files.
The metadata section starts with a '# [Gedit Tool]' line, and each following line from the metadata section should start with '# '. Those lines contain key/value pairs, in the form of 'key=value'. Current keys are:
- Name: the tool name, as displayed in the menu
- Comment: the tool tooltip that appears in the statusbar
- Shortcut: the keyboard shortcut, in usual gtk format.
- Input: the input (nothing, document, selection, line, word or nothing)
- Output: the output (output-panel, new-document, append-document, replace-document, replace-selection or insert)
- Applicability: all, titled, local, remote, or untitled
The rest of the file is the script to be ran. Note that it is good practice to begin the file with a shebang (ex: #!/bin/perl) so that the system knows which interpretor it should use.
You can also share your home-grown tools by copying the relevant file in your home directory.
Tips and tricks
You can use xargs (combined to the Selection input) to use the selected text as an argument for you command. Here is an exemple using that facility to show the manpage of the selected term :
- Label: Manpage
- Commands : xargs man
- Input: Current word
- Output: Output panel
Current Features
An awful lot
Possible Features
- bind tools to a particular set of mime-type
- organize the tools using a tree hierarchy instead of a flat list
- save accelerators updated through direct editing from menu
- quiet mode (no logging of stderr nor status info) for X apps launching
Screenshots
