How do I create a Bash alias?

后端 未结 16 634
一个人的身影
一个人的身影 2020-11-28 17:38

I\'m on OSX and I need to put something like this, alias blah=\"/usr/bin/blah\" in a config file but I don\'t know where the config file is.

16条回答
  •  迷失自我
    2020-11-28 18:19

    The config file for scripts and programs is ~/.bashrc and the config file that gets loaded when you use Terminal is ~/.bash_login.

    I think the best way is to just have everything in ~/.bashrc.

    For your specific question just enter (this will overwrite any existing ~/.bashrc):

    echo "alias blah=\"/usr/bin/blah\"" >>~/.bashrc
    

    into the Terminal and a ~/.bashrc file will be created with your new alises. After that just edit the file to add new aliases, functions, settings etc.

提交回复
热议问题