3

Is it possible to create a button (attached to the Terminal in Gnome) that runs a command in the current Terminal window?

Just being lazy really but rather than typing out terraform init, terraform plan over and over again, it would be really handy if there was a button I could click that would simply run one of those commands.

  • Anything is possible as long as you have the right skills... If you're proficient with c, gtk+ you could alter gnome-terminal source code and add a button that does that... For the people who are "just being lazy" I'd recommend an alias though... – don_crissti Sep 20 '17 at 18:14
  • I would rather try to add a key alias / hotkey to enter a string a of text in the current window, whatever it is. These tools exist. – Ned64 Sep 21 '17 at 10:33
  • @Ned64 The problem with a key alias is it's yet another thing to remember. A button is way easier. – Snowcrash Sep 22 '17 at 9:07
  • Well, you could put a sticker on an F- or other special key. But better (easier) yet ... – Ned64 Sep 22 '17 at 9:23
1

Make a shell alias, that is much, much easier than changing gnome-terminal's GUI (as there is no option for it, you would need to code it):

Assuming you are using bash, put the following into ~/.bashrc:

alias ti='terraform init'
alias tp='terraform plan'

If you use tcsh the equivalent would be

alias ti 'terraform init'
alias tp 'terraform plan'

in your ~/.tcshrc (ideally in a section that is excluded in non-interactive mode).

After installing these aliases and starting a new shell you can type these aliases with many fewer keystrokes than the whole command.

Also easier than typing the whole command would be to use your commandline history. One can search backward in the previously entered commands for those that start with letters. In bash you can start backwards search in history with Ctrl+r, then start typing and using cursor keys Up/Down. In tcsh this is a litte easier, just type the first few letters (e.g. te), then search for previous/next command lines starting with the letters entered, by pressing Alt+p/Alt+n.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.