17

I need to have multiple aliases for one command. I've done it like that:

alias lwbc='$(npm bin)/webpack'
alias lwpc=lwbc

Is this a correct way?

6
  • 1
    Did you try it?
    – SauceCode
    Commented Feb 20, 2017 at 18:58
  • @SauceCode, sure, it works Commented Feb 20, 2017 at 18:58
  • Great. But then you need to clarify what you mean when you ask if it's correct.
    – SauceCode
    Commented Feb 20, 2017 at 19:01
  • @SauceCode, optimal way maybe Commented Feb 20, 2017 at 19:51
  • 1
    To state the obvious, if you later decide to change the command executed by the lwbc alias, it will also affect what the lwpc alias does. If that is what you intend, then your alias is fine.
    – SauceCode
    Commented Feb 20, 2017 at 20:23

1 Answer 1

20

You could use brace expansion. alias {name1,name2}="echo hello" or for your example alias lw{p,b}c="$(npm bin)/webpack" https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .