如何在终端中设置标题

fal*_*lse 4 gnome-terminal

在以前的 Ubuntu 版本中,例如 14.04,可以通过菜单设置每个终端选项卡的标题:终端 -> 设置标题...

在 18.04 中,仍然有带有设置字符编码等选项的终端终端,但缺少设置标题。

那么如何在较新版本中设置标题?

cma*_*.fr 9

此功能自 gnome 3 起被移除
但是,gnome 2 终端已分叉为 mate-terminal,它具有您想要的功能。

sudo apt-get install mate-terminal
Run Code Online (Sandbox Code Playgroud)


如果您想保留 gnome 3 终端并同意从命令行重命名选项卡,您可以尝试以下操作:

1- 将函数“set-title”添加到 .bashrc
2- 重命名终端标题set-title The New Title Name

nano ~/.bashrc

##Add the following to the .bashrc file
function set-title() {
  if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
  fi
  TITLE="\[\e]2;$*\a\]"
  PS1=${ORIG}${TITLE}
}
Run Code Online (Sandbox Code Playgroud)

用法 : set-title My Tab Title