bashwindows-subsystem-for-linuxtitle

Is there a `title` of Windows CMD in Linux


I'm trying to make a CLI with cross-platform support using Python and whenever the user starts the CLI it changes the title of the terminal. In Windows, I would use title but in Linux I don't know

By the way, I use WSL (Windows Subsystem for Linux) and I need in a Python app so it has to work with os.system()

I tried asking ChatGPT but it failed instead of changing the title of the window, it change it to this:

notmithun@HPE-BOOK840:~/scripts$ echo -ne '\\033]0;My new title\\007'
\033]0;My new title\007notmithun@HPE-BOOK840:~/scripts$

TL;DR: What I want is to change the title of the Terminal window in Linux, similar to title in CMD


Solution

  • As @F.Hauri and @Cyrus suggested, you would need an another command running. Since, I am using a Python CLI, the title doesn't go away until it returns to it's shell.

    In Python, you would do:

    os.system("echo -en '\033]0;My new title\007'")
    

    Or for more options,

    print("\33]0;My new title\7")
    

    The second option is more recommend.

    Thank you @F.Hauri and @Cyrus for answering this!