2

For instance the terminal shortcut ctrl+shift+T opens a new terminal - regardless of whether or not there's already a running instance.

How can I make it so that ctrl+shift+T works as follows:

if there is instance of terminal
   switch to it
else
   open new instance
user516728
  • 47
  • 5

1 Answers1

1

You could do it this way:

Install "wm_ctrl" first, then create a script file with the following contents:

#!/bin/bash

    if [ "$(ps -C $1| grep $1 | awk '{print $1}')" = "" ]; then
        $1
        else
            wmctrl -ia "$(wmctrl -lp | grep "$(pgrep "$1")" | tail -1 | awk '{ print $1 }')"
    fi

If you save the file as e.g. "try.sh", execute it with:

./try.sh firefox

if you want to test it with Firefox.

Frank
  • 11
  • 2