Search code examples
hotkeysgnome-terminal

How can I make a hot-key (eg F9) run a specific command in an already open gnome-terminal?


I use a terminal for just about everything. There are a few commands that I often execute within a directory like:

emacs main.tex
evince main.pdf

It may seem silly, I'd like to be able to run a set of commands like this with a single keystroke. Is there any way to map (say) F9 to write a specific sequence of characters to an open gnome terminal?


Solution

  • gnome-terminal doesn't have such a feature, but you might configure bash (actually, readline) to insert a certain string for a given key. Edit ~/.inputrc or /etc/inputrc and add such lines:

    "\e[19~": "emacs main.tex"
    "\e[20~": "evince main.pdf"
    

    Watch out: When you press F8 or F9, these will do exactly the same as if you've typed those characters; no matter what the context is. E.g. if you type rm and then press space, F8, Enter, you'll remove your main.tex!