Create multiple shell aliases at once
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
8
down vote
favorite
I want to insert into alias different possible variants of spelling, for example, cat
command. Can I do it using some symbol for 'or' or should it be on a new line?
alias at|cart|cst '/bin/cat'
command-line alias
add a comment |Â
up vote
8
down vote
favorite
I want to insert into alias different possible variants of spelling, for example, cat
command. Can I do it using some symbol for 'or' or should it be on a new line?
alias at|cart|cst '/bin/cat'
command-line alias
7
Reminds me of one alias I have:alias kk='ll'
â RoVo
May 16 at 7:42
14
I wouldn't recommend usingat
as an alias forcat
. There's an actual commandat
for scheduling stuff: askubuntu.com/a/339301/295286
â Sergiy Kolodyazhnyy
May 16 at 8:02
add a comment |Â
up vote
8
down vote
favorite
up vote
8
down vote
favorite
I want to insert into alias different possible variants of spelling, for example, cat
command. Can I do it using some symbol for 'or' or should it be on a new line?
alias at|cart|cst '/bin/cat'
command-line alias
I want to insert into alias different possible variants of spelling, for example, cat
command. Can I do it using some symbol for 'or' or should it be on a new line?
alias at|cart|cst '/bin/cat'
command-line alias
edited May 16 at 7:57
Melebius
3,65041636
3,65041636
asked May 16 at 7:32
Josef Klimuk
542112
542112
7
Reminds me of one alias I have:alias kk='ll'
â RoVo
May 16 at 7:42
14
I wouldn't recommend usingat
as an alias forcat
. There's an actual commandat
for scheduling stuff: askubuntu.com/a/339301/295286
â Sergiy Kolodyazhnyy
May 16 at 8:02
add a comment |Â
7
Reminds me of one alias I have:alias kk='ll'
â RoVo
May 16 at 7:42
14
I wouldn't recommend usingat
as an alias forcat
. There's an actual commandat
for scheduling stuff: askubuntu.com/a/339301/295286
â Sergiy Kolodyazhnyy
May 16 at 8:02
7
7
Reminds me of one alias I have:
alias kk='ll'
â RoVo
May 16 at 7:42
Reminds me of one alias I have:
alias kk='ll'
â RoVo
May 16 at 7:42
14
14
I wouldn't recommend using
at
as an alias for cat
. There's an actual command at
for scheduling stuff: askubuntu.com/a/339301/295286â Sergiy Kolodyazhnyy
May 16 at 8:02
I wouldn't recommend using
at
as an alias for cat
. There's an actual command at
for scheduling stuff: askubuntu.com/a/339301/295286â Sergiy Kolodyazhnyy
May 16 at 8:02
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
17
down vote
accepted
The help for alias
indicates that it can assign multiple aliases at once:
alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
So you can use brace expansion to generate the name=value
pairs:
alias at,cart,cst='/bin/cat'
So:
$ alias at,cart,cst='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'
That said, look in to zsh, which has built-in typo correction (which wouldn't help for at
, but it would help for the others):
% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
/etc/passwd
If you press
y
when the shell asks you if you want to correct a
word, it will be corrected. If you pressn
, it will be left alone.
Pressinga
aborts the command, and pressinge
brings the line up
for editing again, in case you agree the word is spelled wrong but you
don't like the correction.
add a comment |Â
up vote
7
down vote
I don't think you can assign multiple aliases at once.
But you could loop through a list like this:
for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done
Make sure that the aliases are not already in use by other programs (like at
in your example).
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
2
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
2
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
17
down vote
accepted
The help for alias
indicates that it can assign multiple aliases at once:
alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
So you can use brace expansion to generate the name=value
pairs:
alias at,cart,cst='/bin/cat'
So:
$ alias at,cart,cst='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'
That said, look in to zsh, which has built-in typo correction (which wouldn't help for at
, but it would help for the others):
% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
/etc/passwd
If you press
y
when the shell asks you if you want to correct a
word, it will be corrected. If you pressn
, it will be left alone.
Pressinga
aborts the command, and pressinge
brings the line up
for editing again, in case you agree the word is spelled wrong but you
don't like the correction.
add a comment |Â
up vote
17
down vote
accepted
The help for alias
indicates that it can assign multiple aliases at once:
alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
So you can use brace expansion to generate the name=value
pairs:
alias at,cart,cst='/bin/cat'
So:
$ alias at,cart,cst='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'
That said, look in to zsh, which has built-in typo correction (which wouldn't help for at
, but it would help for the others):
% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
/etc/passwd
If you press
y
when the shell asks you if you want to correct a
word, it will be corrected. If you pressn
, it will be left alone.
Pressinga
aborts the command, and pressinge
brings the line up
for editing again, in case you agree the word is spelled wrong but you
don't like the correction.
add a comment |Â
up vote
17
down vote
accepted
up vote
17
down vote
accepted
The help for alias
indicates that it can assign multiple aliases at once:
alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
So you can use brace expansion to generate the name=value
pairs:
alias at,cart,cst='/bin/cat'
So:
$ alias at,cart,cst='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'
That said, look in to zsh, which has built-in typo correction (which wouldn't help for at
, but it would help for the others):
% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
/etc/passwd
If you press
y
when the shell asks you if you want to correct a
word, it will be corrected. If you pressn
, it will be left alone.
Pressinga
aborts the command, and pressinge
brings the line up
for editing again, in case you agree the word is spelled wrong but you
don't like the correction.
The help for alias
indicates that it can assign multiple aliases at once:
alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
So you can use brace expansion to generate the name=value
pairs:
alias at,cart,cst='/bin/cat'
So:
$ alias at,cart,cst='/bin/cat'
$ type at cart cst
at is aliased to `/bin/cat'
cart is aliased to `/bin/cat'
cst is aliased to `/bin/cat'
That said, look in to zsh, which has built-in typo correction (which wouldn't help for at
, but it would help for the others):
% setopt correct
% sl
zsh: correct `sl' to `ls' [nyae]? y
% setopt correctall
% ls x.v11r4
zsh: correct `x.v11r4' to `X.V11R4' [nyae]? n
/usr/princton/src/x.v11r4 not found
% ls /etc/paswd
zsh: correct to `/etc/paswd' to `/etc/passwd' [nyae]? y
/etc/passwd
If you press
y
when the shell asks you if you want to correct a
word, it will be corrected. If you pressn
, it will be left alone.
Pressinga
aborts the command, and pressinge
brings the line up
for editing again, in case you agree the word is spelled wrong but you
don't like the correction.
answered May 16 at 8:49
muru
129k19271460
129k19271460
add a comment |Â
add a comment |Â
up vote
7
down vote
I don't think you can assign multiple aliases at once.
But you could loop through a list like this:
for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done
Make sure that the aliases are not already in use by other programs (like at
in your example).
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
2
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
2
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
add a comment |Â
up vote
7
down vote
I don't think you can assign multiple aliases at once.
But you could loop through a list like this:
for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done
Make sure that the aliases are not already in use by other programs (like at
in your example).
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
2
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
2
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
add a comment |Â
up vote
7
down vote
up vote
7
down vote
I don't think you can assign multiple aliases at once.
But you could loop through a list like this:
for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done
Make sure that the aliases are not already in use by other programs (like at
in your example).
I don't think you can assign multiple aliases at once.
But you could loop through a list like this:
for a in cart xat vat xst cst vst dog; do alias "$a"='/bin/cat'; done
Make sure that the aliases are not already in use by other programs (like at
in your example).
edited May 16 at 8:05
answered May 16 at 7:49
RoVo
4,756932
4,756932
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
2
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
2
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
add a comment |Â
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
2
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
2
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
Thanks for the answer it works well. I have one of my linux machines with tsch as default. I tried this: foreach x ( cst cart );alias $x='/bin/cat';end.
â Josef Klimuk
May 16 at 9:49
2
2
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@JosefKlimuk: Sounds like it would be worth its own answer. :-)
â David Foerster
May 16 at 10:22
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
@David Foerster, Should I ask it as independent question?
â Josef Klimuk
May 16 at 10:37
2
2
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
@JosefKlimuk: No. I mean that you should write a proper answer to this question based on your previous comment.
â David Foerster
May 16 at 16:09
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1036830%2fcreate-multiple-shell-aliases-at-once%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
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
7
Reminds me of one alias I have:
alias kk='ll'
â RoVo
May 16 at 7:42
14
I wouldn't recommend using
at
as an alias forcat
. There's an actual commandat
for scheduling stuff: askubuntu.com/a/339301/295286â Sergiy Kolodyazhnyy
May 16 at 8:02