mac每次打开终端都需要source ~/.bashrc以及~/.bash_profile问题

问题描述

在学习git的时候在~/.bashrc下面配置了git log命令的别名

#用于输出git提交日志
alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'

但是在使用过程中出现了出现了报错,命令不存在,每次打开终端都需要source一下

在网上找了教程即在~/.bash_profile下添加配置

# 加载.bashrc文件
if [ -f ~/.bashrc ];then
source ~/.bashrc
fi

 

 

尝试之后发现每次打开终端还是需要source一下,同时也发现了~/.bash_profile的问题,也没瞎忙。

最终解决办法

在~/.bash_profile下添加配置如上代码的同时还需要在~/.zshrc添加下面的命令,随便找个地方添加就行了

source ~/.bash_profile

 

 总结

后面也了解到也可以把别名直接配置在~/.zshrc文件中问题一样可以解决

posted on 2022-02-09 23:32  yang_12138  阅读(557)  评论(0编辑  收藏  举报