Dummy OmegaT tags


Now you’re working on a nice text with very few tags. The recipe with nice navigation between tags is quite good, but somewhat cumbersome for just two or three tags you have to insert here and there.


Minimizing the number of keystrokes to insert tags and staying mouse-free while doing that.


So, here’s the solution. The following script inserts a dummy tag at the cursor position, moves the cursor inside the tag, waits for 3 seconds, and then moves cursor outside the tag on the right. Optionally (disabled/commented out here — lines 13 and 17) there is automatic keyboard layout switching to English while the cursor is inside the tag, and back to whatever the layout was on before.
Bash script that requires only coreutils, one of the programs to manipulate xclipboard (xclip here) and something to simulate keystrokes (xte from xautomation). Keyboard switching is done with kbdd.

#Instert dummy tag into OmegaT
#by Kos Ivantsov
#coreutils, xautomation, xclip
#kbdd (optional)

PREVCLIP=`xclip -o -selection clipboard`
echo '</>' | tr -d '\n' | xclip -i -selection clipboard
xte "keydown Control_L" "key v" "keyup Control_L"
xte "key Left" "key Left"
# dbus-send --dest=ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.set_layout uint32:0
echo "$PREVCLIP"| xclip -i -selection clipboard
sleep 3
xte "key Right" "key Right"
# dbus-send --dest=ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.prev_layout

The script should be saved somewhere with a convenient name, made executable, and then assigned a key combination using your WM or tools like xbindkeys

Good luck!

Idea taken from Will Helton

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s