Understanding bashrc vs .bash_profile vs .zshrc When delving into the world of command-line interfaces (CLI), you might have encountered files like .bashrc, .bash_profile, and .zshrc. The “rc” suffix, found in names like .bashrc or .zshrc, originates from “run commands.” Often, it sources .bashrc for consistency. .zshrc: Usage: Zsh’s non-login shell sessions. Relies on .bashrc or .zshrc in Zsh’s case.
传到github做个备份吧~ zshrc配置
existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc. existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc. existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc. existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc. existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.
在知乎大神的基础上进行修改,配置自己的.zshrc repo地址 : https://github.com/yiny0liuyin/zshconfig.zshrc.git ---- 效果 图片加载失败! https://github.com/yiny0liuyin/zshconfig.zshrc/blob/master/media/Xnip2018-08-29_16-36-40.png? && cd zshconfig.zshrc && mv 安装antigen.zshrc ~/.zshrc && zsh COPY 使用 安装完成后 请执行 bash 1cd && cd zshconfig.zshrc && mv .zshrc ~/.zshrc COPY 如果你觉得麻烦请执行(忽略以上两条代码) bash 1git clone https://github.com/yiny0liuyin/zshconfig.zshrc.git && cd zshconfig.zshrc && mv 原始.zshrc ~/.zshrc && zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ "$KEEP_ZSHRC" = yes ]; then echo "${YELLOW}Found ~/.zshrc. ${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh ${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi echo "${GREEN
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then # Skip this if the user doesn't want to replace an existing .zshrc if [ "$KEEP_ZSHRC" = yes ]; then echo "${YELLOW}Found ~/.zshrc. ${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh ${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi echo "${GREEN
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." \ "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc. ${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi echo "${GREEN}Using \" " ~/.zshrc > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc echo } setup_shell() { # Skip setup
source ~/.zshrc env echo -e 'export LANG=zh_CN.UTF-8' >> ~/.zshrc echo -e 'export LC_CTYPE="zh_CN.UTF -8"' >> ~/.zshrc ##################################### echo -e 'export yourpath=/Users/user/Documents ' >> ~/.zshrc echo -e 'export PATH=$PATH:$yourpath/java/maven/bin' >> ~/.zshrc echo -e 'alias proxy=" ~/.zshrc echo -e 'alias typora="/usr/bin/open -a Typora $@"' >> ~/.zshrc echo -e 'alias sqlmap="python3 $yourpath/sqlmap/sqlmap.py $@"' >> ~/.zshrc
existing .zshrc if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc. ${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh ${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi echo "${GREEN 配置文件 vi ~/.zshrc 这时我们再次打开zshrc文件进行编辑。
方案一:统一管理 —— 在 .zshrc 中加载 .bash_profile 如果你已经配置了 .bash_profile,可以通过 .zshrc 引用它,实现配置复用。 1. 编辑 .zshrc 文件 vim ~/.zshrc 在文件末尾添加一行: # 加载 bash 配置,确保 adb 等命令可用 source ~/.bash_profile 优点:一次配置,双 shell 使配置立即生效 source ~/.zshrc 方案二:原生支持 Zsh —— 直接写入 .zshrc 如果你偏好纯粹使用 zsh,不依赖 .bash_profile,可以直接将环境变量写入 .zshrc 四、常见问题与排查 问题 可能原因 解决方法 command not found: adb .zshrc 未生效 检查是否执行了 source ~/.zshrc adb: Permission denied 通过 source ~/.bash_profile 可实现兼容,但直接写入 .zshrc 更简洁。
(0) Exit, creating the file ~/.zshrc containing just a comment. Found /home/vvd/.zshrc. look over the `.zshrc` file to select plugins, themes, and options. 自定义别名,在 ~/.zshrc 中,最下面直接写即可。 Found ~/.zshrc.pre-oh-my-zsh -- Restoring to ~/.zshrc Found ~/.zshrc -- Renaming to ~/.zshrc.omz-uninstalled
文章目录 令人蛋疼的事 百因必有果 你的报应就是我 其他 参考资料 如果你懒得看整个过程,就直接: 编辑.zshrc文件,在最后追加一个source命令 zhenghui@192 ~ % zhenghui @192 ~ % cat ~/.zshrc #每次用户进入之后使bash_profile生效 source ~/.bash_profile zhenghui@192 ~ % 令人蛋疼的事 ? ~/.zshrc ~/.zlogin ~/.zlogout 你的报应就是我 在bash中我们可以看到咱们熟悉的“bash_profile”配置文件,但是在zsh中始终没有看到“bash_profile 可以看到只有“.zshrc”文件,可以得出一个解决,那么用户下默认执行的肯定就是“.zshrc”文件了 zhenghui@192 ~ % zhenghui@192 ~ % ls -a |egrep -e "zshenv|zprofile|zshrc|zlogin|zlogout" .zshrc zhenghui@192 ~ % zhenghui@192 ~ % 编辑.zshrc文件,在最后追加一个
enter 3、source ~/.bash_profile 使其生效 第二种报错(使用的是zsh或oh-my-zsh) zsh: command not found adb:adb 1、vim ~/.zshrc ,如果.zshrc不存在,先touch ~/.zshrc 2、将如下内容添加到.zshrc文件中 ...... => enter 3、source ~/.zshrc 使其生效 ps:.zshrc是zsh的配置文件,相当于bash的.bash_profile,添加相应的环境变量即可
试着编辑他 vi ~/.zshrc G到最后一行o 在下方插入一个新行并进入编辑模式试着加一行输出编辑再新开终端然后重新打开一个xfce终端编辑 这说明新开终端的时候就会执行 ~/.zshrc因为我们默认的 ~加入到$PATH的路径列表中~/.zshrc# 编辑zsh的配置文件rc(run command)vi ~/.zshrc 编辑这个配置文件 在尾行下面加一句话export PATH=$PATH:~可能不一定是 124行只要是最后一行就行编辑 以后只要是进 zsh $PATH 列表中就会包含用户文件夹~(/home/shiyanlou) 可是 这个 ~/.zshrc 到底是啥意思理解rc文件 ~/.zshrc vimrc~/.bashrc编辑 这个初始化程序对于新建的终端窗口是好用的 但是还得重启一下zsh才能应用我想要就在当前的zsh下运行一把~/.zshrc可以么? 运行当前zsh的初始化文件 运行~/.zshrc配置文件 source ~/.zshrc这就是手动执行执行~/.zshrc或者直接运行zsh也可以编辑 执行之后 路径就设置好了总结 这次修改了 $PATH
导致问题:只有在终端执行bash_profile,别名才会生效,每次重启iTerm2后命令就会失效 source ~/.bash_profile 解决办法 将bash_profile中别名alias配置写在zshrc 中,这样就解决了iTerm2重启后别名alias失效的问题 vi ~/.zshrc 原理 其实这个原理还是相当于:只有每次重启的时候在终端执行bash_profile:source ~/.ba sh_profile ,别名才会生效 因为当iTerm2一旦启动,就会自动执行zshrc文件, zshrc中的配置都是全局配置 注意! 注意使用的shell版本: zsh对应的是zshrc bash对应的是basic 在解决别名alias重启终端失效问题的时候,网上的解决办法都是在bashrc中添加配置,我尝试了怎么也没成功 后来,突然想到之前使用过的 zshrc文件 原来是我之前配置oh-my-zsh时把终端shell从bash替换到了zsh,这样使用zshrc后完美解决问题
为 ~/.zshrc.pre-oh-my-zsh; 生成新的 ~/.zshrc,并自动切换到 Zsh。 理解 ~/.zshrc 结构 安装完成后,打开 ~/.zshrc,你会发现日志注释很多、配置项丰富。 小贴士: 每次修改完 ~/.zshrc 后,需执行 source ~/.zshrc 才能使新配置生效。 ' # 编辑 .zshrc alias ezsh='code ~/.zshrc' # 查找端口占用(macOS) alias psg='lsof -i :' # 其他别名... 问题 3:source ~/.zshrc 后没有效果(插件不生效/主题不生效) 排查思路: 确保 ~/.zshrc 文件末尾没有语法错误,特别是引号和括号是否成对。
本人在 Linux/Mac的命令行通过配置 `~/.zshrc` 文件实现了在窗口启动及调用`jj`命令时自动重置$GOPATH的功能。 步骤一:打开 `~/.zshrc` 文件 vim ~/.zshrc 步骤二:将下面代码拷贝到 `~/.zshrc` 文件中,并保存 function setgopath() { currpath echo '$GOPATH:'$GOPATH fi fi } jj () { cd $1 setgopath } 步骤三:使配置生效 source ~/.zshrc
% mv -b \ ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc 3、编辑配置文件 默认情况下,Oh My Zsh 自带的配置文件是非常简陋的。 % cat ~/.zshrc~ >> ~/.zshrc 看一下默认的配置文件以及它提供的一些选项。用你最喜欢的编辑器打开 ~/.zshrc 文件。这个文件有非常良好的注释。 ➜ ~ sed -i 's/_THEME=\"robbyrussel\"/_THEME=\"linuxonly\"/g' ~/.zshrc ➜ ~ source ~/.zshrc seth@darkstar 为了激活这个扩展,你可以将这个扩展添加到你的配置文件 ~/.zshrc 中。 % source ~/.zshrc 这个扩展现在就可以使用了。
亲测有效): 比如让root用户使用和wt用户相同的配置: sudo ln -s $HOME/.oh-my-zsh /root/.oh-my-zsh sudo ln -s $HOME/.zshrc /root/.zshrc 切换到root用户,命令zsh,即可看到zsh的主题和wt用户的一样了。 如果提示 /root/.zshrc:119: command not found: pyenv /root/.zshrc:120: command not found: pyenv 再创建.pyenv的软连接即可 如果要个性化,可以用 sudo cp -r /home/wt/.oh-my-zsh /root sudo cp -r /home/wt/.zshrc /root
y 下面的Ubuntu和Centos是一样的 克隆仓库 git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh 备份原来的zshrc ,如果文件存在的话 cp ~/.zshrc ~/.zshrc.bak 创建一个新的zsh配置文件 cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc