Automatically apply the current working path as a title to the command line window.

Microsoft Windows
Post Reply
Pete
Posts: 3
Joined: 2023-May-30, 7:59 am

Automatically apply the current working path as a title to the command line window.

Post by Pete »

Hello!

I'm looking for a way to apply automatically a title to the command line window,
whenever I open one by "Open command window here" option in the context menu of explorer;
particularly I want to put as title the current working path-name inside which the window has been opened.
Reason is that usually I maintain several terminal windows opened, and when I need to focus on and restore any of them,
I want to be able to quickly locate it by it's title shown in the jump-list.
Currently what is shown as title is a generic (and useless for the purpose) "Command line".
PS. I hope I've made clear enough my query -- english is not my mother tongue.

regards,
Pete
User avatar
Simon Sheppard
Posts: 190
Joined: 2021-Jul-10, 7:46 pm
Contact:

Re: Automatically apply the current working path as a title to the command line window.

Post by Simon Sheppard »

If you go into the registry
HKCU\Software\Microsoft\Command Processor\

Create a new string value called:
AutoRun

set it to:

Code: Select all

TITLE %cd%
That will set the title of each new CMD window (wherever it is opened from) to the current directory when opened, just be aware that if you change directory the title will not automatically update.
Pete
Posts: 3
Joined: 2023-May-30, 7:59 am

Re: Automatically apply the current working path as a title to the command line window.

Post by Pete »

Simon Sheppard wrote: 2023-Jun-01, 4:30 pm ...
Create a new string value called:
AutoRun
set it to:

Code: Select all

TITLE %cd%
That will set the title of each new CMD window (wherever it is opened from) to the current directory when opened,
Excellent tip! it works like a charm.
Thank you very much!
just be aware that if you change directory the title will not automatically update.
Now that's a really interesting remark. Since tweaking or even substituting the <cd> command,
being it an internal one, doesn't seem feasible (I'd wish it to be ), a first thought is to introduce
an "extended" <cdx> "command", by creating a little two-lines batch script and moving it into "system32" folder.
Sth like:

Code: Select all

::cdx.bat
@cd %1
@title %cd%
Not exactly elegant and hardly convenient workaround, though. Any suggestion would be greatly appreciated!

regards,
Pete
Simon_Weel
Posts: 34
Joined: 2021-Dec-13, 3:53 pm

Re: Automatically apply the current working path as a title to the command line window.

Post by Simon_Weel »

Maybe >> this << will work?
Pete
Posts: 3
Joined: 2023-May-30, 7:59 am

Re: Automatically apply the current working path as a title to the command line window.

Post by Pete »

Simon_Weel wrote: 2023-Jun-07, 3:04 pmMaybe >> this << will work?
Interesting thread for the matter, tried the accepted answer (particularly as improved by a comment under it), and works fine.
Thanks for the link!
Post Reply