Run Shell Commands In Almost Any Application That Supports Typing Text With Shin
Shin (shell input method) is a tool that lets you run shell commands in almost any text input on your Linux desktop. It's implemented as an IBus input engine, and it works with almost every desktop application, on both X11 and Wayland.
To see how Shin works, I've created this short video:
In this video, I use a keyboard shortcut to activate Shin and run a shell command in a text editor. The keyboard shortcut I use is not shown in the video because I've had some issues with Screenkey (which I've used before to show pressed keyboard keys in videos).
Shin features:
- works with most Linux applications including GTK and Qt apps, Firefox, Chrome, LibreOffice, etc.
- is activated using a keyboard shortcut; until it's used, it doesn't use any CPU or memory
- it has a history of previously ran shell commands – press the keyboard shortcut you've set up to run it, then use the
Up
/Down
arrow keys to browse through previously ran shell commands - use Shin-specific commands by placing executable scripts in the
~/.config/shin/bin
directory (which you'll need to create, since it's not automatically created) - this way, they are only available to Shin; it's worth noting that Shin doesn't support Bash aliases for now
I stumbled upon Shin when trying to find an easy to use Autokey text expansion tool that works on Wayland. But that's just my use case – I'm sure you can think of other useful use cases for Shin, depending on what you need.
If you want to use it like me, for text expansion, here's an example in which we'll create an abbreviation :sig
which we'll expand to My really long signature text
, which you can obviously customize to your liking:
- create the
~/.config/shin/bin
folder - in this folder, create a file named
:sig
(make sure that the filename you're using is not already used by a command, that's why I prefer to add:
at the beginning) - make the
:sig
file from~/.config/shin/bin
executable - inside the file, add the following line:
echo "My really long signature text"
Now when you press the keyboard shortcut used to activate Shin, then type :sig
and press the Enter
key, Shin will replace the typed :sig
text with My really long signature text
.
This is a very simple use-case for Shin, the tool can do much more than that!
In case Shin doesn't work for you, its developer recommends checking that your IBus setup is actually working. You could for example install Typing Booster (which adds predictive typing to the Linux desktop) and verify that's working. In my case, I didn't have any IBus input methods added which caused some weird behavior in Shin (which only worked in some windows), so I added an input method for English by running the ibus-setup
command in a terminal (then add the input method on the Input Method
tab).
Install and setup Shin
To be able to use Shin, you'll need to have IBus installed and configured. IBus is used by default on GNOME desktops, so there's no need to do anything if you're using GNOME. For other desktop environments, see the IBus configuration instructions from the Arch wiki; I've also explained how to set up IBus in this article about Typing Booster.
On Arch Linux / Manjaro you can install Shin from AUR.
Install Shin from source
1. To install Shin from source, you'll first need to install Go and Git:
- Debian, Ubuntu, Linux Mint and other Debian or Ubuntu-based Linux distributions:
sudo apt install golang-go git
- Fedora:
sudo dnf install golang-go git
2. Get the latest Shin code from Git and install it using the following commands:
git clone https://github.com/p-e-w/shin.git
cd shin
make
sudo make install
After this, you'll need to restart IBus, which is done using the ibus restart
command. This didn't work for me though, and Shin didn't work until I restarted the session (logout / relogin).
To use Shin, you'll need to assign a keyboard shortcut in your desktop environment settings for the ibus engine shin
command. You can add a keyboard shortcut for your desktop environment as follows:
- Newer GNOME versions (e.g. 42 and 43):
Settings -> Keyboard -> View and Customize Shortcuts -> Custom Shortcuts -> +
(scroll to the bottom) - Older GNOME versions (e.g. 3.36):
Settings -> Keyboard Shortcuts -> +
(scroll to the bottom) - Cinnamon:
System Settings -> Keyboard -> Shortcuts -> Custom Shortcuts -> Add custom shortcut
- KDE Plasma:
System Settings -> Shortcuts -> Custom Shortcuts -> Edit -> New -> Global Shortcut -> Command / URL
- Xfce:
Settings -> Keyboard -> Application Shortcuts -> Add
Most desktop environment have an option for setting a keyboard shortcut, but I can't cover all of them. If you use some other desktop environment, hopefully you know, or you can figure out how to add a custom shortcut yourself, and if not, search the web for how to do it.
Now give Shin a try. Open a text editor, type a shell command (e.g. date
) and press the Enter
key to substitute the shell command with its output in the text editor.