Text expander for linux
I wanted some fuzzy feeling in the way I can search in my abbrevations. And some interaction with greenclip.
Two new tools in the spirit of texpander
For this to work one needs
For arch based linux one can do
yay -S rofi-greenclip zsh xsel xdotool systemctl --user enable greenclip.service
follow the rest of the original guide to setup this scipts in your desktop environment.
Texpander is a simple text expander for Linux. It is sort of like Autokey, except it works off of text files that you put in your
~/.texpanderdirectory. Texpander is a bash script that uses xclip, xdotool, and zenity to let you type an abbreviation for something and it expands to whatever you have in the matching text file.
texpander.shsomewhere on your system, perhaps your
~/.texpanderdirectory where you store text files for expanding abbreviations
Texpander relies on a couple command line tools:
If those aren't already installed on your system you can probably grab them from your distros package manager without any trouble. For example for Ubuntu you can get what you need with the following commands.
sudo apt install xsel sudo apt install xdotool sudo apt install zenity
The text expansion files reside in your
~/.texpanderdirectory and can be organized in subdirectories. Name the files in the format of
abbreviationwhere the filename is the thing you want to type and the content of the file is what you want to have pasted into your document.
crtl+spaceassigned to run
~/bin/texpander.sh. So, if I'm typing an email, it doesn't matter if I'm in gmail (using Firefox, Chrome, Opera, or Vivaldi), Thunderbird, Vim, or Nylas, the workflow is the same. I have a couple different email signatures that I use. For example, if want to use my email signature, I'll create a file
~/.texpander/sig.txtthat has all of my contact information.
This process may be slightly different for you depending on what desktop environment and Linux distribution you have. I've personally tested this on Pop!_OS and Elementary OS 5.1 but each desktop environment has a slightly different way of setting up keyboard shortcuts. But the bottom line is I just map
After setting up the keyboard shortcut to launch Texpander, to use Texpander:
Ctrl+Shift+T(or whatever keyboard shortcut you set up)
sigand hit Enter (or click "OK")
~/.texpander/sig.txtis pasted into your document
If I'm not in a web browser I'm in the terminal working in Vim. I've got some texpander files that I use in Vim. The terminal works a little differently from other GUI apps in that you have to type
ctrl+shift+vto paste stuff. In texpander.sh there is a check to see if the active window is a terminal. If so, it will paste using
ctrl+shift+vif not then it will paste normally as
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
Version 2.0 - November 24, 2017
xcliptends to strip newlines when pasting into certain application like Gmail on Firefox.
shift+Insertto be compatible with more programs for pasting rather than trying to figure out if the current app should use
typemode so if pasting doesn't work, the
type(rather than paste) text into the active window.
Version 1.1.1 - November 22, 2016
Version 1.1 - November 7, 2016
Version 1.0.1 - June 23, 2016
Version 1.0 - May 17, 2016
Written by Lee Blue
General Public License v3.0