Is it possible for make to create aliases?

Here's what I tried:


  alias hello='echo world'
  alias holy='echo cow'

It doesn't work as-is, presumably because the alias command runs outside the context of the shell. Is it possible to execute them in-context? Or "export" the created aliases somehow?

If not, what's the best alternative to bringing aliases to a host in bulk? (As add-ons in a repo, for example.)

  • The best you can do is add them to ~/.bash_aliases and they will be loaded the next time bash is restarted. If you don't want to restart, you can type . ~/.bash_aliases to import manually.
    – AFH
    Mar 20 '18 at 17:32
  • Do you want run hello command to echo world? Or why do you need it?
    – uzsolt
    Mar 20 '18 at 18:59
  • @uzsolt As a silly example, yes. In my current use-case, leaning towards just copying small shell scripts to /usr/local/bin or something -- None of my aliases, thus far, do anything more than proxy for other commands and scripts.
    – svidgen
    Mar 20 '18 at 19:11
  • 1
    Unfortunately, you can't. More information in this post: stackoverflow.com/questions/50939213/makefile-to-add-aliases Jun 25 '18 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.