最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - How to Disable Terminal Title Change When Running Node or npm Commands - Stack Overflow

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论