bash 在 Ubuntu 中为 Terminator(控制台应用程序)中的选项卡设置标题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5343265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting Title for Tabs in Terminator (Console Application) in Ubuntu
提问by Xprog
Is there way to set terminator (Version: 0.95ppa1) title of tabs to a different string via bash command-line (CLI)?
有没有办法通过 bash 命令行(CLI)将选项卡的终止符(版本:0.95ppa1)标题设置为不同的字符串?
I plan to use this feature with AutoKey and I can open multiple machines at same time and set title to Name of the machine its connected to.
我计划将此功能与 AutoKey 一起使用,我可以同时打开多台机器并将标题设置为其连接的机器的名称。
回答by Bolster
ORIG=$PS1
TITLE="\e]2;\"This is just crazy enough to work\"\a"
PS1=${ORIG}${TITLE}
Resets title to
将标题重置为
"This is just crazy enough to work"
“这太疯狂了,可以工作”
This should apply to all xterm-style terminal emulators.
这应该适用于所有 xterm 风格的终端模拟器。
回答by Logg
From the Terminator man pages,
从终结者手册页,
Ctrl+Alt+W Rename window title.
Ctrl+Alt+A Rename tab title.
Ctrl+Alt+X Rename terminal title.
Ctrl+Alt+W 重命名窗口标题。
Ctrl+Alt+A 重命名选项卡标题。
Ctrl+Alt+X 重命名终端标题。
You can also launch a new instance with
您还可以启动一个新实例
$ terminator --title [title]
$ 终结者 --title [title]
回答by Raghav Mehta
Add follwing in your .bashrc
file by editing it using vim ~/.bashrc
and use set_title
to rename your tab:
.bashrc
通过使用编辑文件在文件中添加以下内容vim ~/.bashrc
并使用set_title
重命名选项卡:
set_title()
{
ORIG=$PS1
TITLE="\e]2;$*\a"
PS1=${ORIG}${TITLE}
}
run source ~/.bashrc
command after editing your .bashrc
file
source ~/.bashrc
编辑.bashrc
文件后运行命令
Ex.: set_title newtab
will rename your current tab to newtab
例如:set_title newtab
将您当前的标签重命名为newtab
working Properly in Gnome3.14 terminal and terminator 0.97
在 Gnome3.14 终端和终结器 0.97 中正常工作
回答by Thomas Dignan
PS1 does not need to be set. Credit for this function goes to geirha on freenode #bash
PS1 不需要设置。此功能归功于 freenode #bash 上的 geirha
set_title() { printf '\e]2;%s\a' "$*"; }
set_title() { printf '\e]2;%s\a' "$*"; }
回答by AAAfarmclub
This seems to work for me. I'm using BASH on Crunchbang (Debian derived)
这似乎对我有用。我在 Crunchbang(Debian 派生的)上使用 BASH
$ echo -en '\e]0;echo works too\a'
回答by Ximon Eighteen
With Terminator 0.96 and GNU bash 4.2.25 the printf
suggestion above worked for me, but I had to tweak it slightly to make it into a function that would just work for me in a new Terminator tab. I added this to the end of my ~/.bashrc
file:
使用 Terminator 0.96 和 GNU bash 4.2.25printf
上面的建议对我有用,但我不得不稍微调整它以使其成为一个仅在新的 Terminator 选项卡中对我有用的功能。我将此添加到我的~/.bashrc
文件末尾:
set_title() { printf "\e]2;$*\a"; }
set_title() { printf "\e]2;$*\a"; }
The key was placing the \a
at the end of the quoted string. Then when opening a new tab in Terminator I can use this like so:
关键是将 放在\a
带引号的字符串的末尾。然后在 Terminator 中打开一个新标签时,我可以这样使用:
set_title "My new tab title"
set_title "我的新标签标题"
Apologies to those who already stated the essentials of this answer, but since I found that I had to make slight changes to get it to work for me, this my also benefit someone else.
向那些已经说明了这个答案的要点的人道歉,但由于我发现我必须做一些细微的改变才能让它对我有用,这也有利于其他人。
回答by linitux
On Terminator 1.91-6 double click terminal title enables edition
On Terminator 1.91-6 双击终端标题启用版
回答by n.shalnov
Try add PROMPT_COMMAND='echo -en "\033]0; $("pwd") \a"'
in your .bashrc
尝试添加PROMPT_COMMAND='echo -en "\033]0; $("pwd") \a"'
您的 .bashrc
回答by whatever
For terminator 0.98 (Ubuntu 16.04 MATE), right clicking the title enables renaming it.
对于终结者 0.98 (Ubuntu 16.04 MATE),右键单击标题可以重命名它。
回答by Sarvesh
Right click on terminator and choose preferences from the drop-down menu. Choose profiles tab and enable "show title bar" option. It works!!
右键单击终止符并从下拉菜单中选择首选项。选择配置文件选项卡并启用“显示标题栏”选项。有用!!
Tip: You can actually rename each terminator window!!
提示:您实际上可以重命名每个终结符窗口!!