Useful DosKey + Command window titles


Mark got me mucking with my doskey macros again, and between the two of us came up with a fairly elegant mechanism that keeps the title of a command line reflecting the current directory you're in:



First, you need a little script turd that does this:

@%*
@title %CD% - %OTHER_STUFF_YOU_MIGHT_WANT_IN_YOUR_TITLE%

I named that script 'ttl.cmd' and stick it in my %SCRIPTS% directory.  Then, my doskey macro file that I run for command windows that I open contains this:

cd..=%SCRIPTS%\ttl cd ..
cd=%SCRIPTS%\ttl cd /D $*
pushd=%SCRIPTS%\ttl pushd $*
popd=%SCRIPTS%\ttl popd $*
a:=%SCRIPTS%\ttl a:
b:=%SCRIPTS%\ttl b:
c:=%SCRIPTS%\ttl c:
d:=%SCRIPTS%\ttl d:
e:=%SCRIPTS%\ttl e:
f:=%SCRIPTS%\ttl f:
g:=%SCRIPTS%\ttl g:
h:=%SCRIPTS%\ttl h:
i:=%SCRIPTS%\ttl i:
j:=%SCRIPTS%\ttl j:
k:=%SCRIPTS%\ttl k:
l:=%SCRIPTS%\ttl l:
m:=%SCRIPTS%\ttl m:
n:=%SCRIPTS%\ttl n:
o:=%SCRIPTS%\ttl o:
p:=%SCRIPTS%\ttl p:
q:=%SCRIPTS%\ttl q:
r:=%SCRIPTS%\ttl r:
s:=%SCRIPTS%\ttl s:
t:=%SCRIPTS%\ttl t:
u:=%SCRIPTS%\ttl u:
v:=%SCRIPTS%\ttl v:
w:=%SCRIPTS%\ttl w:
x:=%SCRIPTS%\ttl x:
y:=%SCRIPTS%\ttl y:
z:=%SCRIPTS%\ttl z:

And now you get the command window title to track the directory that you're currently located in. The only gotcha is that you can't do <space>cd foo because that prevents doskey macros from running.


-Kev


Comments (5)
  1. msvista says:

    Nice one ..thanks…

  2. This is great.

    We should also mention that, if something goes awry, you can always just run ttl.cmd manually to fix things (assuming %SCRIPTS% is in your path).

  3. Tony says:

    FreiK,

    Do known if there is any public documentation regarding "@" usage? I couldn’t find any using searches. Thanks.

  4. Kevin Frei says:

    @ is basically a way to prevent the command from echoing, even if echo is on. I can’t find any docs on it in the help…

  5. John says:

    Regarding @, invoke the help:

    c:>HH NTCMDS.CHM

    Find the help for the ‘echo’ command. See the Remarks.

Comments are closed.

Skip to main content