I am using Windows Terminal, and the shell I use doesn't matter. For example, this issue occurs with both PowerShell and Command Prompt.
When I start the shell, the Windows Terminal title is set to something like "PowerShell (v7)," which is a custom title I configured within Windows Terminal.
However, when I run any npm command, such as npm --version or npm --help, the terminal title temporarily changes to "npm" before reverting back to my custom title. I would like to know how to prevent this title change specifically for npm commands.
I am aware that Windows Terminal has a setting to block title changes entirely, but I don't want to disable title changes globally because I still need the ability to change the title in other contexts. I am looking for a solution to prevent npm from changing the title when it runs.
Interestingly, when I run other programs, such as Deno, the terminal title does not change, which leads me to believe that the title change is not caused by PowerShell itself but rather by npm.
Since I know that terminal titles can be changed by sending escape sequences to stdout, I tried redirecting both stdout and stderr to files using a command like npm --version > out.txt 2> err.txt. However, this did not prevent the title from changing.
Is there a way to disable npm's behavior of changing the terminal title?