美文网首页
MAC 下自定义命令/命令映射

MAC 下自定义命令/命令映射

作者: liwen2015 | 来源:发表于2018-10-25 13:29 被阅读2次

    Keyword: alias

    Example:

    alias pull = 'git pull origin'
    alias push = 'git push origin'
    alias add = 'git add .'
    alias commit = 'git commit -m'
    alias checkout = 'git checkout'
    alias status = 'git status'
    -----------------------------------------
    alias demo='cd /xxx/xxx/xxx  && python demo.py'
    

    将所有的alias 的命令保存于 ~/.bashrc文件(没有则创建此文件),然后输入:
    source ~/.bashrc

    在此之前,保证有 ~/.bash_profile 文件(没有则创建此文件),在其中加入一行
    source ~/.bashrc

    ~/.bash_profile 是终端每次启动时自动执行的文件

    当你使用了zsh时,设置自动加载.bash_profile的方法如下:
    sudo vim ~/.zsh
    在最后面添加一行代码
    source ~/.bash_profile
    这样重启terminal时就能自动加载.bash_profile文件了。

    相关文章

      网友评论

          本文标题:MAC 下自定义命令/命令映射

          本文链接:https://www.haomeiwen.com/subject/bwwqtqtx.html