如何在 Mac OS X 中任意更改终端窗口的标题?我见过这个问题和这个magicwrap 东西,但认为它只是一个简单的 Mac OS X 命令。
Dan*_*ath 49
这篇文章告诉你如何。
本质上,您使用回显到屏幕的字符序列来通知终端它应该显示什么标题。
title='My first title'
echo -n -e "\033]0;$title\007"
Run Code Online (Sandbox Code Playgroud)
在上面的例子中,无论变量 title 设置为 while 成为终端的标题。当然,您可以只在字符串中使用标题来回显,例如:
echo -n -e "\033]0;My first title\007"
Run Code Online (Sandbox Code Playgroud)
但是第一种方法使它更容易使用和/或稍后扩展。
小智 37
将以下内容添加到您的~/.profile将实现相同的效果:
# function for setting terminal titles in OSX
function title {
printf "\033]0;%s\007" "$1"
}
Run Code Online (Sandbox Code Playgroud)
然后快速title 'et voila'将所有选项卡整理出来。
Dan MgG 答案的混音:
echo -n -e "\033]0;$1\007"
Run Code Online (Sandbox Code Playgroud)
将其存储在名为 /usr/bin/title 的文件中(使用 sudo!)并将其 chmod 为 +x。然后你可以从任何地方输入
title 'Trying to Figure This GIT Thing Out'
Run Code Online (Sandbox Code Playgroud)
你会得到一个漂亮的小标题。
(如果我没有理解正确的话,如果你不在 OSX 上,语法可能会有所不同)
| 归档时间: |
|
| 查看次数: |
36149 次 |
| 最近记录: |