【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
miniconda 安装后在zsh下不能补全提示 着实让人头疼,经过一番折腾:
conda-env 单独的命令。
官方的 conda init zsh 貌似只能把conda加入到环境变量 其他啥也没用,难道我的环境问题?
(base) ✘ ⚡ root@iZ2ze3s31vnb0o5bur3ix0Z ~ conda init zsh
no change /usr/local/miniconda3/condabin/conda
no change /usr/local/miniconda3/bin/conda
no change /usr/local/miniconda3/bin/conda-env
no change /usr/local/miniconda3/bin/activate
no change /usr/local/miniconda3/bin/deactivate
no change /usr/local/miniconda3/etc/profile.d/conda.sh
no change /usr/local/miniconda3/etc/fish/conf.d/conda.fish
no change /usr/local/miniconda3/shell/condabin/Conda.psm1
no change /usr/local/miniconda3/shell/condabin/conda-hook.ps1
no change /usr/local/miniconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change /usr/local/miniconda3/etc/profile.d/conda.csh
no change /root/.zshrc
No action taken.
conda的默认知识:
mkdir ~/.oh-my-zsh/plugins/conda
cd ~/.oh-my-zsh/plugins/conda
将他的拷贝进去
https://github.com/drdavella/oh-my-conda/blob/master/_conda
稍加修改env获取方式:
env_list=($(for i in `cat ~/.conda/environments.txt`; basename $i))
(base) ✘ ⚡ root@iZ2ze3s31vnb0o5bur3ix0Z ~ cd ~/.oh-my-zsh/plugins/conda
(base) ⚡ root@iZ2ze3s31vnb0o5bur3ix0Z ~/.oh-my-zsh/plugins/conda master ● cat _conda
#compdef conda
#autoload
_conda_env_list() {
#env_list=($(ls "$_CONDA_ROOT/envs" | xargs -n 1))
env_list=($(for i in `cat ~/.conda/environments.txt`; basename $i))
}
_arguments \
'(-h --help)'{-h,--help}'[Show this help message and exit]' \
'(-V --version)'{-V,--version}'[Show the conda version number and exit]' \
'*:: :->subcmds' && return 0
local -a _1st_arguments
_1st_arguments=(
'clean:Remove unused packages and caches.'
'config:Modify configuration values in .condarc.'
'create:Create a new conda environment from a list of specified packages.'
'help:Displays a list of available conda commands and their help strings.'
'info:Display information about current conda install.'
'install:Installs a list of packages into a specified conda environment.'
'list:List linked packages in a conda environment.'
'package:Low-level conda package utility. (EXPERIMENTAL)'
'remove:Remove a list of packages from a specified conda environment.'
'uninstall:Alias for conda remove.'
'search:Search for packages and display associated information.'
'update:Updates conda packages to the latest compatible version.'
'upgrade:Alias for conda update.'
'activate:Activate given environment.'
'deactivate:Deactivate current environment.'
)
if (( CURRENT == 1 )); then
_describe -t commands "conda subcommand" _1st_arguments
return
fi
case "$words[1]" in
install)
_arguments \
'(-n --name)'{-n,--name}'[Name of environment]: :->env_list'
if [[ "$state" == "env_list" ]]; then
_conda_env_list
_wanted env_list expl 'environments' compadd -a env_list
fi;;
activate)
_conda_env_list
_wanted env_list expl 'environments' compadd -a env_list
;;
esac
vim /root/.zshrc
加入刚刚的文件夹
关闭shell 再打开,完成。
conda-env 没有考虑进去 其实也不用了 能activate就行。
每次进入 bash 不自动 activate base env:
conda config --set auto_activate_base false
来源:oschina
链接:https://my.oschina.net/VASKS/blog/3144300