How do I set the aliases to echo the commands before executing on Windows












0















I am setting command line aliases on Windows using doskey /MACROFILE=foo.txt.



Before executing each command, I would like my command prompt to echo the actual command that I would be executing through aliases



My set_aliases.bat file looks like this:



DOSKEY /MACROFILE="foo.txt"


My foo.txt looks like this



cdhome=cd c:
...
other aliases that I want to set
...


If I execute the cdhome command, I would like my command prompt to be doing this:



*** executing aliases: cd c: ***


before executing the command.



How would I achieve this on Windows?










share|improve this question













migrated from stackoverflow.com Feb 12 at 5:46


This question came from our site for professional and enthusiast programmers.



















  • First, understand what these aliases are. They aren't implemented by the CMD shell. By default doskey.exe creates aliases for CMD, i.e. it calls AddConsoleAlias with ExeName set to "cmd.exe". Console aliases substitute the alias target when the alias source string matches the beginning of a line when the console reads in line-input mode (i.e. ENABLE_LINE_INPUT). The alias substitution has already occurred in a line of input that CMD read from the console.

    – eryksun
    Feb 11 at 23:21











  • This will probably help but has been a while. I checked an old file I have. You can do (from the command line) e.g. doskey z=(echo abc ^& dir) so in a macros file probably similar but without the word 'doskey'(you can experiment with escaping the ampersand or not). And i think you can do in a macros file z=blah.bat $* There can be whatever commands in that bat.

    – barlop
    Feb 12 at 17:59


















0















I am setting command line aliases on Windows using doskey /MACROFILE=foo.txt.



Before executing each command, I would like my command prompt to echo the actual command that I would be executing through aliases



My set_aliases.bat file looks like this:



DOSKEY /MACROFILE="foo.txt"


My foo.txt looks like this



cdhome=cd c:
...
other aliases that I want to set
...


If I execute the cdhome command, I would like my command prompt to be doing this:



*** executing aliases: cd c: ***


before executing the command.



How would I achieve this on Windows?










share|improve this question













migrated from stackoverflow.com Feb 12 at 5:46


This question came from our site for professional and enthusiast programmers.



















  • First, understand what these aliases are. They aren't implemented by the CMD shell. By default doskey.exe creates aliases for CMD, i.e. it calls AddConsoleAlias with ExeName set to "cmd.exe". Console aliases substitute the alias target when the alias source string matches the beginning of a line when the console reads in line-input mode (i.e. ENABLE_LINE_INPUT). The alias substitution has already occurred in a line of input that CMD read from the console.

    – eryksun
    Feb 11 at 23:21











  • This will probably help but has been a while. I checked an old file I have. You can do (from the command line) e.g. doskey z=(echo abc ^& dir) so in a macros file probably similar but without the word 'doskey'(you can experiment with escaping the ampersand or not). And i think you can do in a macros file z=blah.bat $* There can be whatever commands in that bat.

    – barlop
    Feb 12 at 17:59
















0












0








0








I am setting command line aliases on Windows using doskey /MACROFILE=foo.txt.



Before executing each command, I would like my command prompt to echo the actual command that I would be executing through aliases



My set_aliases.bat file looks like this:



DOSKEY /MACROFILE="foo.txt"


My foo.txt looks like this



cdhome=cd c:
...
other aliases that I want to set
...


If I execute the cdhome command, I would like my command prompt to be doing this:



*** executing aliases: cd c: ***


before executing the command.



How would I achieve this on Windows?










share|improve this question














I am setting command line aliases on Windows using doskey /MACROFILE=foo.txt.



Before executing each command, I would like my command prompt to echo the actual command that I would be executing through aliases



My set_aliases.bat file looks like this:



DOSKEY /MACROFILE="foo.txt"


My foo.txt looks like this



cdhome=cd c:
...
other aliases that I want to set
...


If I execute the cdhome command, I would like my command prompt to be doing this:



*** executing aliases: cd c: ***


before executing the command.



How would I achieve this on Windows?







windows cmd.exe alias






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 11 at 17:02







Alboss











migrated from stackoverflow.com Feb 12 at 5:46


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Feb 12 at 5:46


This question came from our site for professional and enthusiast programmers.















  • First, understand what these aliases are. They aren't implemented by the CMD shell. By default doskey.exe creates aliases for CMD, i.e. it calls AddConsoleAlias with ExeName set to "cmd.exe". Console aliases substitute the alias target when the alias source string matches the beginning of a line when the console reads in line-input mode (i.e. ENABLE_LINE_INPUT). The alias substitution has already occurred in a line of input that CMD read from the console.

    – eryksun
    Feb 11 at 23:21











  • This will probably help but has been a while. I checked an old file I have. You can do (from the command line) e.g. doskey z=(echo abc ^& dir) so in a macros file probably similar but without the word 'doskey'(you can experiment with escaping the ampersand or not). And i think you can do in a macros file z=blah.bat $* There can be whatever commands in that bat.

    – barlop
    Feb 12 at 17:59





















  • First, understand what these aliases are. They aren't implemented by the CMD shell. By default doskey.exe creates aliases for CMD, i.e. it calls AddConsoleAlias with ExeName set to "cmd.exe". Console aliases substitute the alias target when the alias source string matches the beginning of a line when the console reads in line-input mode (i.e. ENABLE_LINE_INPUT). The alias substitution has already occurred in a line of input that CMD read from the console.

    – eryksun
    Feb 11 at 23:21











  • This will probably help but has been a while. I checked an old file I have. You can do (from the command line) e.g. doskey z=(echo abc ^& dir) so in a macros file probably similar but without the word 'doskey'(you can experiment with escaping the ampersand or not). And i think you can do in a macros file z=blah.bat $* There can be whatever commands in that bat.

    – barlop
    Feb 12 at 17:59



















First, understand what these aliases are. They aren't implemented by the CMD shell. By default doskey.exe creates aliases for CMD, i.e. it calls AddConsoleAlias with ExeName set to "cmd.exe". Console aliases substitute the alias target when the alias source string matches the beginning of a line when the console reads in line-input mode (i.e. ENABLE_LINE_INPUT). The alias substitution has already occurred in a line of input that CMD read from the console.

– eryksun
Feb 11 at 23:21





First, understand what these aliases are. They aren't implemented by the CMD shell. By default doskey.exe creates aliases for CMD, i.e. it calls AddConsoleAlias with ExeName set to "cmd.exe". Console aliases substitute the alias target when the alias source string matches the beginning of a line when the console reads in line-input mode (i.e. ENABLE_LINE_INPUT). The alias substitution has already occurred in a line of input that CMD read from the console.

– eryksun
Feb 11 at 23:21













This will probably help but has been a while. I checked an old file I have. You can do (from the command line) e.g. doskey z=(echo abc ^& dir) so in a macros file probably similar but without the word 'doskey'(you can experiment with escaping the ampersand or not). And i think you can do in a macros file z=blah.bat $* There can be whatever commands in that bat.

– barlop
Feb 12 at 17:59







This will probably help but has been a while. I checked an old file I have. You can do (from the command line) e.g. doskey z=(echo abc ^& dir) so in a macros file probably similar but without the word 'doskey'(you can experiment with escaping the ampersand or not). And i think you can do in a macros file z=blah.bat $* There can be whatever commands in that bat.

– barlop
Feb 12 at 17:59












0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1404716%2fhow-do-i-set-the-aliases-to-echo-the-commands-before-executing-on-windows%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown
























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1404716%2fhow-do-i-set-the-aliases-to-echo-the-commands-before-executing-on-windows%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How do I know what Microsoft account the skydrive app is syncing to?

When does type information flow backwards in C++?

Grease: Live!