1

I've setup a permanent doskey by a doskey macro file as per this answer. However, if I use a command that is listed there, it double prints the current working directory (top terminal).

image

It seems to have something to do with the $T since it works normally when the macro file only contains 1 doskey alias as per the bottom terminal in the picture.

How do I fix this?

Biswapriyo
  • 11,584

1 Answers1

0

The previous thread is incorrect, and the $T token should not be used at the end of a macro. It acts as a command separator within a single DOSKEY macro definition; not as a separator between multiple definitions. (A regular line break is enough for that.)

DOSKEY macros work by transforming input before it's seen by the actual program (Cmd). Each $T in the macro becomes a line break (Enter ↵ keypress) in the expanded output. For example, if you had typed e Hello!:

  • the macro e=echo $* generates echo Hello!;
  • the macro e=echo $* $T generates echo Hello! ;
  • the macro e=echo $* $T echo Bye! generates echo Hello! echo Bye!.

(Of course, when making DOSKEY macros for Cmd, you can use the normal & or && as a command separator. However, that's not available in other interactive programs – DOSKEY is a generic feature and could be used to make aliases for tools like Netsh, or the MySQL interactive client. Some of them only allow one command per line, therefore a DOSKEY macro needs $T to send multiple commands at once.)

grawity
  • 501,077