Change gnome-terminal title to reflect the current directory?

后端 未结 5 1626
深忆病人
深忆病人 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:50

    I'm not an expert but you should try to edit your ~/.bashrc file. If I understood your problem correctly you can change your .bashrc according to my (I'm using Ubuntu 12.04). The "old" line is commented out and the new one is below it (with additional comment).

    case "$TERM" in
    xterm*|rxvt*)
      # OLD PS1 directive
        #PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
      # NEW PS1 directive, shows only current directory name as terminal window name
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\W\a\]$PS1"
        ;;
    *)
        ;;
    esac
    

    The result is that my terminal title is equal to my current directory title eg. after cd Documents/projects my terminal title is projects (if file is open the terminal name is its name)

提交回复
热议问题