Is there any way to create bash like aliases in windows (powershell or cmd)?

Multi tool use
I want to create an alias that can still take input, like:
alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist
Is this possible within windows?
I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.
windows-10 powershell cmd.exe
add a comment |
I want to create an alias that can still take input, like:
alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist
Is this possible within windows?
I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.
windows-10 powershell cmd.exe
add a comment |
I want to create an alias that can still take input, like:
alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist
Is this possible within windows?
I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.
windows-10 powershell cmd.exe
I want to create an alias that can still take input, like:
alias ytx='youtube-dl -ciw -f bestaudio --yes-playlist
Is this possible within windows?
I tried bash aliases equivalent for powershell? but it doesn't allow for input at the end.
windows-10 powershell cmd.exe
windows-10 powershell cmd.exe
asked Jan 1 at 19:46


Timen ZandbergenTimen Zandbergen
82
82
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH
.
For passing input to batch files, use %*
, which evaluates to "all parameters passed to the batch file command line", or, use %1
, %2
, ... %9
to refer to individual parameters.
Personally, I keep my batch files in C:Batch
and place it in the begining of my PATH
. When running the batch files, you could omit the .bat
suffix, to get a similar look-and-feel to bash aliases.
Few examples of my own:
s3cmd.bat
, which contains:python c:devtoolss3cmd-2.0.0s3cmd %*
.
All parameters are passed directly to the actuals3cmd
program.
clangcheck.bat
, which is a shorthand for:
clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*
. Here, the batch parameters are passed along with extra arguments toclang-check
.
epoch_to_time.bat
, which converts Unix epoch time to readable local time.
It contains:perl -pe "s/([d]{10})/localtime $1/eg;" %1
. Here,%1
is the epoch time to convert, which is expected as a single parameter.
add a comment |
The equivalent command is the
doskey command, which you may use as:
doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*
where $*
represents all the parameters.
Here is a small example that echos its parameters:
Doskey can also be used in PowerShell. For more information see
this answer.
For making a doskey macro persistent across sessions, see the post
Create permanent DOSKEY in Windows cmd.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389589%2fis-there-any-way-to-create-bash-like-aliases-in-windows-powershell-or-cmd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH
.
For passing input to batch files, use %*
, which evaluates to "all parameters passed to the batch file command line", or, use %1
, %2
, ... %9
to refer to individual parameters.
Personally, I keep my batch files in C:Batch
and place it in the begining of my PATH
. When running the batch files, you could omit the .bat
suffix, to get a similar look-and-feel to bash aliases.
Few examples of my own:
s3cmd.bat
, which contains:python c:devtoolss3cmd-2.0.0s3cmd %*
.
All parameters are passed directly to the actuals3cmd
program.
clangcheck.bat
, which is a shorthand for:
clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*
. Here, the batch parameters are passed along with extra arguments toclang-check
.
epoch_to_time.bat
, which converts Unix epoch time to readable local time.
It contains:perl -pe "s/([d]{10})/localtime $1/eg;" %1
. Here,%1
is the epoch time to convert, which is expected as a single parameter.
add a comment |
The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH
.
For passing input to batch files, use %*
, which evaluates to "all parameters passed to the batch file command line", or, use %1
, %2
, ... %9
to refer to individual parameters.
Personally, I keep my batch files in C:Batch
and place it in the begining of my PATH
. When running the batch files, you could omit the .bat
suffix, to get a similar look-and-feel to bash aliases.
Few examples of my own:
s3cmd.bat
, which contains:python c:devtoolss3cmd-2.0.0s3cmd %*
.
All parameters are passed directly to the actuals3cmd
program.
clangcheck.bat
, which is a shorthand for:
clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*
. Here, the batch parameters are passed along with extra arguments toclang-check
.
epoch_to_time.bat
, which converts Unix epoch time to readable local time.
It contains:perl -pe "s/([d]{10})/localtime $1/eg;" %1
. Here,%1
is the epoch time to convert, which is expected as a single parameter.
add a comment |
The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH
.
For passing input to batch files, use %*
, which evaluates to "all parameters passed to the batch file command line", or, use %1
, %2
, ... %9
to refer to individual parameters.
Personally, I keep my batch files in C:Batch
and place it in the begining of my PATH
. When running the batch files, you could omit the .bat
suffix, to get a similar look-and-feel to bash aliases.
Few examples of my own:
s3cmd.bat
, which contains:python c:devtoolss3cmd-2.0.0s3cmd %*
.
All parameters are passed directly to the actuals3cmd
program.
clangcheck.bat
, which is a shorthand for:
clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*
. Here, the batch parameters are passed along with extra arguments toclang-check
.
epoch_to_time.bat
, which converts Unix epoch time to readable local time.
It contains:perl -pe "s/([d]{10})/localtime $1/eg;" %1
. Here,%1
is the epoch time to convert, which is expected as a single parameter.
The simplest approach, which works in any Windows version, is using common batch files, stored in a common folder available in your PATH
.
For passing input to batch files, use %*
, which evaluates to "all parameters passed to the batch file command line", or, use %1
, %2
, ... %9
to refer to individual parameters.
Personally, I keep my batch files in C:Batch
and place it in the begining of my PATH
. When running the batch files, you could omit the .bat
suffix, to get a similar look-and-feel to bash aliases.
Few examples of my own:
s3cmd.bat
, which contains:python c:devtoolss3cmd-2.0.0s3cmd %*
.
All parameters are passed directly to the actuals3cmd
program.
clangcheck.bat
, which is a shorthand for:
clang-check -analyze -extra-arg -Xclang -extra-arg -analyzer-output=text %*
. Here, the batch parameters are passed along with extra arguments toclang-check
.
epoch_to_time.bat
, which converts Unix epoch time to readable local time.
It contains:perl -pe "s/([d]{10})/localtime $1/eg;" %1
. Here,%1
is the epoch time to convert, which is expected as a single parameter.
edited Jan 1 at 20:12
answered Jan 1 at 20:01


valianovaliano
229110
229110
add a comment |
add a comment |
The equivalent command is the
doskey command, which you may use as:
doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*
where $*
represents all the parameters.
Here is a small example that echos its parameters:
Doskey can also be used in PowerShell. For more information see
this answer.
For making a doskey macro persistent across sessions, see the post
Create permanent DOSKEY in Windows cmd.
add a comment |
The equivalent command is the
doskey command, which you may use as:
doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*
where $*
represents all the parameters.
Here is a small example that echos its parameters:
Doskey can also be used in PowerShell. For more information see
this answer.
For making a doskey macro persistent across sessions, see the post
Create permanent DOSKEY in Windows cmd.
add a comment |
The equivalent command is the
doskey command, which you may use as:
doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*
where $*
represents all the parameters.
Here is a small example that echos its parameters:
Doskey can also be used in PowerShell. For more information see
this answer.
For making a doskey macro persistent across sessions, see the post
Create permanent DOSKEY in Windows cmd.
The equivalent command is the
doskey command, which you may use as:
doskey ytx=youtube-dl -ciw -f bestaudio --yes-playlist $*
where $*
represents all the parameters.
Here is a small example that echos its parameters:
Doskey can also be used in PowerShell. For more information see
this answer.
For making a doskey macro persistent across sessions, see the post
Create permanent DOSKEY in Windows cmd.
answered Jan 1 at 20:24


harrymcharrymc
257k14269571
257k14269571
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1389589%2fis-there-any-way-to-create-bash-like-aliases-in-windows-powershell-or-cmd%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
v 1RCF8,Fu,oOv4 O