command prompt title bar

D

DbDutch

Is it possible to change the title of the command prompt to reflect the
current directory?

I can use $P$G to get the current drive and directory, but that eats up
screen real estate. I have tried adding $_ which acts like and CrLf, but I
don't like it as much.

I realize this is petty, but just curious. I tried changing the properties
of the shortcut, but came up empty.

All thoughts, flames, and ideas gratefully accepted.
 
D

Dean Wells [MVP]

Not in realtime no, you can of course set the title to the current
directory using -

title %CD%

.... but that's only going to set the title to the current-directory at
the time the command is executed, once you change directory the title
will continue to reflect the previous current-directory.

You might consider writing a simple script that wraps the CD command for
you -

[SD.CMD]
@echo off
cd %*
title %CD%
[/SD.CMD]

.... now, when changing directory, use the SD command instead of CD.
Ensure SD.CMD is placed somewhere within your system's path. You may
also want to consider using the PUSHD command within the script as
opposed to CD to extend its capabilities.

HTH
 
E

Ed Siff

Make a batch file named mcd.bat with these lines in it and make sure it is in
your path:

@echo off
cls
cd %1
for /f "Tokens=*" %%i in ('CD') do set CurDir=%%i
title %curdir%

Start a command window and type mcd. That should changet the title to the
current dir. When you want to change directories, use mcd instead of cd.

(info found at http://www.jsifaq.com/subj/tip4600/rh4603.htm)

Ed
 
L

Larry__Weiss

Dean said:
You might consider writing a simple script that wraps the CD command for you -

[SD.CMD]
@echo off
cd %*
title %CD%
[/SD.CMD]

... now, when changing directory, use the SD command instead of CD.
Ensure SD.CMD is placed somewhere within your system's path. You may
also want to consider using the PUSHD command within the script as
opposed to CD to extend its capabilities.

That's nice in that if you suspect that you or some other script or
program has used CD or CHDIR (or programmatic equivalent) to change
the current directory, you can just type
SD
with no arguments to ensure that the title is current.

prompt $N:^^

complements using the title bar for the current directory to remind you
where to look for it.

It is a shame that there is not something you could pass to the PROMPT
command to allow "realtime" setting of the title every time the prompt
string is refreshed.

- Larry
 
M

Michael Bednarek

in microsoft.public.win2000.cmdprompt.admin:

[snip]
It is a shame that there is not something you could pass to the PROMPT
command to allow "realtime" setting of the title every time the prompt
string is refreshed.

That's why there are real command line interpreters. CMD.EXE is no more
useful for serious CLI work than WordPad is for serious word processing.
 
C

Charles Dye

in microsoft.public.win2000.cmdprompt.admin:

[snip]
It is a shame that there is not something you could pass to the PROMPT
command to allow "realtime" setting of the title every time the prompt
string is refreshed.

That's why there are real command line interpreters. CMD.EXE is no more
useful for serious CLI work than WordPad is for serious word processing.

E.g. 4NT, which supports:

set titleprompt=$p$g
 
?

=?iso-8859-1?q?J._Baumg=E4rtel?=

Larry__Weiss schrieb:

It is a shame that there is not something you could pass to the PROMPT
command to allow "realtime" setting of the title every time the prompt
string is refreshed.

- Larry

Hi Larry,
try the following:
1. Write the following line to e.g. %systemroot%\system32\doskey.mac:
cd=cd /d $*$Ttitle %cd%
2. Create a link to cmd.exe with the following commandline (one long
line):
%SystemRoot%\system32\cmd.exe /k doskey
/macrofile=%systemroot%\system32\doskey.mac&title %cd%
3. Open your shell via that link and you have what you want.

- there´s only one little problem: you shouldn´t use the syntax cd\
(without blank) anymore, because that isn´t recognized from doskey as
a macro.

-Jochen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top