如何使用快捷键调出最后一个终端窗口?

Kli*_*lik 11 shortcut-keys gnome-terminal

我经常使用终端来发出快速命令,然后我将它留在后台,这样我最终会在工作时打开 20 多个终端会话。这是因为只需使用快捷键并键入命令就非常快捷。

有没有办法设置快捷键,以便我打开最后一个终端窗口而不是创建一个新窗口?

Byt*_*der 13

我有一个终端固定在我的 Unity 启动器侧边栏上的位置 10。这样我就可以按Super+0来“单击”启动器图标,它将最新的终端窗口带到顶部。

在此处输入图片说明

如果将它放在启动器中对您来说没问题(前 10 个位置之一,否则它将无法获得快捷方式!),这将起作用。


Jos*_*Jos 10

我使用guake,我很满意。按F12,出现终端窗口,再按F12,它消失但一直在后台运行。另外:看起来很酷。


Jac*_*ijm 6

您可以将下面的脚本放在组合键下。如果您按下组合键,终端窗口将(完全)消失。再次按下它,它们将再次完全按照您的状态弹出。

您唯一需要(一次)是在终端的窗口名称中添加标识字符串(终端窗口在大多数情况下具有相同的名称)

使用它

安装xdotoolwmctrl

sudo apt-get install xdotool
sudo apt-get install wmctrl
Run Code Online (Sandbox Code Playgroud)
  1. 将脚本复制到一个空文件中,另存为 hide_terminal.py
  2. 在 head 部分,设置终端窗口名称的标识字符串
  3. 在组合键下运行它:

    python3 /path/to/hide_terminal.py
    
    Run Code Online (Sandbox Code Playgroud)

剧本

sudo apt-get install xdotool
sudo apt-get install wmctrl
Run Code Online (Sandbox Code Playgroud)


ter*_*don 5

这与 Jacob Vlijm 的回答是一样的,只是用 bash 写的:

#!/usr/bin/env bash

## window_name will be the first argument passed or, if no
## argument was given, "Terminal"
window_name=${1:-"Terminal"}

## Get the list of open terminals
terms=( $(wmctrl -l | grep "$window_name" | cut -d ' ' -f 1) )

## If all terminals are hidden
if [ -z "${terms[0]}" ]
then
    ## Read the IDs of hidden windows from .hidden_window_id
    while read termid
    do
        xdotool windowmap "$termid"
    done < ~/.hidden_window_id
## If there are visible terminals
else
    ## Clear the .hidden_window_id file
    > ~/.hidden_window_id
    ## For each open terminal
    for i in "${terms[@]}"
    do
        ## Save the current ID into the file
        printf "%s\n" "$i" >> ~/.hidden_window_id
        ## Hide the window
        xdotool windowunmap "$i"
    done
fi
Run Code Online (Sandbox Code Playgroud)

如果将其另存为~/bin/show_hide.sh,则可以通过提供要隐藏的任何窗口的标识字符串来运行它。如果没有给出字符串,它将适用于Terminal

show_hide.sh Terminal
Run Code Online (Sandbox Code Playgroud)