0

Is there a generic text expansion tool in Linux? I have to type some same strings frequently and I want to use abbreviation to type faster.

For example, I type a lot "symbol testapp/testapp.debug" in gdb. I want to create a shortcut "symdbg", so that when I hit TAB, that string will be replaced with "symbol testapp/testapp.debug".

I hope the tool can be generic so I can do it anywhere like terminal/browser/editors.

Edit: I'm using Ubuntu with xmonad, fish shell in urxvt terminal. But tools for other environment are good to know!

strongwillow
  • 109
  • 3
  • 2
    What desktop environment are you using (if any)? This may be doable by the desktop environment, some form of plugin to it, or a separate application, but depending on whether you're on KDE, Gnome or something else, it may work differently. Also mention what terminal application you're using. Please [edit] your question rather than replying in comments. – Kusalananda Mar 09 '20 at 10:51
  • 2
    Have you tried setting aliases in `~/.profile` file? These will be accessible in `gdb`. – Paulo Tomé Mar 09 '20 at 10:57
  • I'm posting this as a comment, because I don't have enough information to write a proper answer, and I don't know whether it will really do what you want.   [AutoKey](https://github.com/autokey/autokey-python2) appears to be sort-of a Linux version of AutoHotkey.   See [Wikipedia](https://en.wikipedia.org/wiki/AutoKey), [lifehacker](https://lifehacker.com/autokey-does-customized-text-replacement-for-linux-5310976), and [another review](https://www.maketecheasier.com/autokey-make-your-own-keyboard-shortcuts-in-linux). – G-Man Says 'Reinstate Monica' Mar 09 '20 at 23:15

2 Answers2

1

An alternative approach is to create a ~/.gdbinit file, see https://www.cse.unsw.edu.au/~learn/debugging/modules/gdb_init_file/

Roel Van de Paar
  • 240
  • 2
  • 12
0

You can define aliases and shell functions. Some editors allow to define abbreviations/shortcuts.

vonbrand
  • 18,156
  • 2
  • 37
  • 59
  • Are you sure? Can you provide a reference? [This](https://unix.stackexchange.com/q/422685/80216 "Why doesn't gdb like aliases?"), for example, seems to contradict your answer, and I couldn't find anything that supports it. – G-Man Says 'Reinstate Monica' Mar 09 '20 at 16:43
  • @G-ManSays'ReinstateMonica', emacs has a system of auto-expansions. Never used it in earnest, more hassle than what it was worth when I fooled around with it, many years back. – vonbrand Mar 09 '20 at 22:15
  • My point is that the question asks for a *generic* tool, that can be used in *any* program.  I interpret this to mean something like AutoHotkey, but that works for abbreviations (sequences on non-modified characters, rather than Shift/Ctrl/Alt keystroke sequences) and works in Linux.  I saw some references to ```gdb``` having some sort of alias capability, but your answer seems to be suggesting that shell aliases and shell functions will automagically work in ```gdb```, and that would be news to me. – G-Man Says 'Reinstate Monica' Mar 09 '20 at 23:01