1

I tried to create alias for argument by putting this code into .bashrc

alias malog="/Applications/MAMP/logs/apache_error.log"

And I tied to call it with different commands, like:

tail -f malog
vim malog

But it didn't work. I know that I can write alias that will work like:

alias tmalog="tail -f /Applications/MAMP/logs/apache_error.log"
alias vmalog="vim /Applications/MAMP/logs/apache_error.log"
...

But, maybe there is a way to create alias for argument/parameter?

2
  • 2
    Aliases will only work at the beginning of a line. Commented Jul 17, 2015 at 9:42
  • 1
    zsh has "global" aliases you can use like this, not bash Commented Jul 17, 2015 at 11:19

1 Answer 1

3

This is not an alias, you just to set a variable with the full pathname:

mhttpd="/Applications/MAMP/conf/apache/httpd.conf"

tail -f "$mhttpd"
vim "$mhttpd"

alias is a shortcut for some command usually so you can use:

alias tail_apache='tail -f /Applications/MAMP/conf/apache/httpd.conf"

and use it as:

tail_apache
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, I'm gonna accept it after a few minutes, cuz I'm getting this message "You can accept an answer in 8 minutes". Again, thank you very much for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.