G
Gnooby
Hi,
I'm trying to make the cmd.exe window display the current working
directory in the title. I managed to do do this somehow, but I'm not
totally satified with the solution. Please take a look:
I created a file named startup.bat. It contains the following:
doskey /macrofile=c:\macrofile.mac
The macrofile.mac contains
cd=(CD $* && c:\set_title.bat)
set_title.bat contains:
@echo off
title %CD%
Then I made the cmd.exe link execute the startup.bat file:
%SystemRoot%\system32\cmd.exe /k c:\startup.bat
This works just fine, but I'm curious how I could do this with just one
file/command. I'm quite a newbie to shell scripting, and I'm simply
missing some syntactic details. So, how would you do this with just
one entry in startup.bat? Obviously none of the following works:
doskey cd=(CD $* && title %CD%)
doskey cd=CD $* $t title %CD%
Of course, this must fail because %CD% is expanded when the 'doskey'
command is executed and not when the 'cd' command is executed.
I don't get the syntax either:
- What about the parenthesis? Do I need them?
- What is the right way to concatenate the commands? '&&' or '$t' ?
I tried to find a decent tutorial/howto, but the Web is flooded with
the spare command reference
Have a nice day.
I'm trying to make the cmd.exe window display the current working
directory in the title. I managed to do do this somehow, but I'm not
totally satified with the solution. Please take a look:
I created a file named startup.bat. It contains the following:
doskey /macrofile=c:\macrofile.mac
The macrofile.mac contains
cd=(CD $* && c:\set_title.bat)
set_title.bat contains:
@echo off
title %CD%
Then I made the cmd.exe link execute the startup.bat file:
%SystemRoot%\system32\cmd.exe /k c:\startup.bat
This works just fine, but I'm curious how I could do this with just one
file/command. I'm quite a newbie to shell scripting, and I'm simply
missing some syntactic details. So, how would you do this with just
one entry in startup.bat? Obviously none of the following works:
doskey cd=(CD $* && title %CD%)
doskey cd=CD $* $t title %CD%
Of course, this must fail because %CD% is expanded when the 'doskey'
command is executed and not when the 'cd' command is executed.
I don't get the syntax either:
- What about the parenthesis? Do I need them?
- What is the right way to concatenate the commands? '&&' or '$t' ?
I tried to find a decent tutorial/howto, but the Web is flooded with
the spare command reference
Have a nice day.