Loading

M1 MacOS 开发环境配置记录

硬件信息

  • Mac mini M1
  • 已安装homebrew

install conda with homebrew

brew install anaconda

补上手动配置环境变量
M1的conda安装位置默认为/opt/homebrew/anaconda3
故只需确认好路径正确即可

# 1️⃣进入vim编辑.zshrc配置文件
vim ~/.zshrc
# 2️⃣插入下面conda初始化代码
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/homebrew/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
        eval "$__conda_setup"
else
if [ -f "/opt/homebrew/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/homebrew/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/homebrew/anaconda3/bin:$PATH"
fi
        fi
unset __conda_setup
# <<< conda initialize <<<

# 3️⃣使生效
source ~/.zshrc

fix conda env show problem

my using theme is bira

set conda env name by your position that you wanted

# 1. cancel default env name show method
conda config --set changeps1 False
# 2. edit theme file
vim ~/.oh-my-zsh/themes/bira.zsh-theme
# 3. add follow codes in the front of 'ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"'
local conda_prompt='$(conda_prompt_info)'
conda_prompt_info() {
    if [ -n "$CONDA_DEFAULT_ENV" ]; then
        echo -n "%{$terminfo[bold]$fg[yellow]%}($CONDA_DEFAULT_ENV) %{$reset_color%}"
    else
        echo -n ''
    fi
}
# 4. edit PROMPT value just like this
PROMPT="╭─${user_host}${conda_prompt}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}
╰─%B${user_symbol}%b "
# 5. restart iTerm
posted @ 2022-10-30 22:02  MrSu  阅读(309)  评论(0编辑  收藏  举报