Change gnome-terminal title to reflect the current directory?

后端 未结 5 1589
深忆病人
深忆病人 2021-02-01 15:16

I want to change the title of the gnome-terminal window to reflect the current directory. Is there a way to do that? A script may be? The \"change terminal title\" threads did n

5条回答
  •  无人及你
    2021-02-01 15:49

    I'm doing it like this to override the cd command and set pwd into the title:

    function title { echo -en "\033]2;$1\007"; }
    function cd { dir=$1; if [ -z "$dir" ]; then dir=~; fi; builtin cd "$dir" && title `pwd`; }
    cd `pwd`
    

    I just threw this into my ~/.bash_aliases. You could probably tweak this to do what you want.

提交回复
热议问题