Change iTerm2 tab title dynamically for Ruby/Rails

自古美人都是妖i 提交于 2019-12-06 23:03:08

问题


I am using iTerm2 and usually have many tabs open. Unfortunately all tabs show me the same title "ruby" as it is all ruby scripts.

But one is rails server, the other rails console, the next is "spork", ... I would like to set the tab titles dynamically to "server", "console" or something similar as long as the processes are running and back to the default ("bash") when they are finished.

Anybody knows how to do this?

Thanks.


回答1:


This command will set a tab's title to MY_NEW_TITLE

echo -e "\033];MY_NEW_TITLE\007"




回答2:


The best way to do this depends on your shell.

I use zsh, which allows you to define hook functions which are run when command are run, before the prompt is printed, etc (actually, the code I'm using lives on github.

It looks as though bash has similar functionality.

I'd probably use the echo command in one of the other answers here, or zsh's title function to set the title from within your scripts, then ensure it's set back using a hook which runs before the next prompt is drawn.



来源:https://stackoverflow.com/questions/6874404/change-iterm2-tab-title-dynamically-for-ruby-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!