最近在用fish shell,但是无法使用conda的activate命令来激活环境.官方给的有解决方案

https://github.com/conda/conda/blob/5b97a96d78e65d8178eb60d36e0fc99cd5b3ab21/bin/conda.fish

将这个里面的内容复制到自己的config.fish在source一下就可以了

#
# Conda environment activate / deactivate functions for fish shell v2.2.0+.
#
# Ivan Smirnov (C)
# #
# INSTALL
#
# Source this file from the fish shell to enable activate / deactivate functions.
# In order to automatically load these functions on fish startup, append
#
# source (conda info --root)/bin/conda.fish
#
# to the end of your ~/.config/config.fish file.
#
# USAGE
#
# To activate an environment (via name or path), you can use one of the following:
#
# activate ENV
# conda activate ENV
#
# To deactivate an environment, use one of:
#
# deactivate
# conda deactivate
#
# To make the env name appear on the left side, set an environment variable:
#
# set -gx CONDA_LEFT_PROMPT
#
# To go back to making the env name appear on the right, erase that variable:
#
# set -e CONDA_LEFT_PROMPT # Require version fish v2.+ to be able to use array slices, `else if`
# and $status for command substitutions
if [ (echo (fish -v ^&) | sed 's/^.*version \([0-9]\)\..*$/\1/') -lt ]
echo 'Incompatible fish shell version; please upgrade to v2.0 or higher.'
exit
end function __conda_delete_function
functions -e $argv
if functions -q $argv
functions -e $argv
end
end function __conda_restore_prompt
if functions -q __fish_prompt_orig
__conda_delete_function fish_prompt
functions -c __fish_prompt_orig fish_prompt
functions -e __fish_prompt_orig
end if functions -q __fish_right_prompt_orig
__conda_delete_function fish_right_prompt
functions -c __fish_right_prompt_orig fish_right_prompt
functions -e __fish_right_prompt_orig
end
end function __conda_backup_prompt
functions -e __fish_prompt_orig
if functions -q fish_prompt
functions -c fish_prompt __fish_prompt_orig
functions -e fish_prompt
else
function __fish_prompt_orig
end
end functions -e __fish_right_prompt_orig
if functions -q fish_right_prompt
functions -c fish_right_prompt __fish_right_prompt_orig
functions -e fish_right_prompt
else
function __fish_right_prompt_orig
end
end
end function __conda_echo_env
set_color normal
echo -n '('
set_color -o green
echo -n $CONDA_DEFAULT_ENV
set_color normal
echo -n ') '
end # Inject environment name into fish_right_prompt / fish_prompt
function __conda_update_prompt
if [ (conda '..changeps1') -eq ]
switch $argv[]
case activate
__conda_restore_prompt
__conda_backup_prompt
function fish_prompt
if set -q CONDA_LEFT_PROMPT
__conda_echo_env
end
__fish_prompt_orig
end
function fish_right_prompt
if not set -q CONDA_LEFT_PROMPT
__conda_echo_env
end
__fish_right_prompt_orig
end
case deactivate
__conda_restore_prompt
end
end
end # Convert colon-separated path to a legit fish list
function __conda_set_path
set -gx PATH (echo $argv[] | tr : \n)
end # Calls activate / deactivate functions if the first argument is activate or
# deactivate; otherwise, calls conda-<cmd> and passes the arguments through
function conda
if [ (count $argv) -lt ]
command conda
else
if [ (count $argv) -gt ]
set ARGS $argv[..-]
else
set -e ARGS
end
switch $argv[]
case activate deactivate
eval $argv
case '*'
command conda $argv
end
end
end # Equivalent to bash version of conda activate script
function activate --description 'Activate a conda environment.'
if [ (count $argv) -lt ]
echo 'You need to specify a conda environment.'
return
end # deactivate an environment first if it's set
if set -q CONDA_DEFAULT_ENV
conda '..checkenv' $argv[]
if [ $status = ]
__conda_set_path (conda '..deactivate')
set -e CONDA_DEFAULT_ENV
__conda_update_prompt deactivate
else
return
end
end # try to activate the environment
set -l NEW_PATH (conda '..activate' $argv[])
if [ $status = ]
__conda_set_path $NEW_PATH
if [ (echo $argv[] | grep '/') ]
pushd (dirname $argv[])
set -gx CONDA_DEFAULT_ENV (pwd)/(basename $argv[])
popd
else
set -gx CONDA_DEFAULT_ENV $argv[]
end
__conda_update_prompt activate
else
return $status
end
end # Equivalent to bash version of conda deactivate script
function deactivate --description 'Deactivate the current conda environment.'
if set -q CONDA_DEFAULT_ENV # don't deactivate the root environment
set -l NEW_PATH (conda '..deactivate' $argv[])
if [ $status = ]
__conda_set_path $NEW_PATH
set -e CONDA_DEFAULT_ENV
__conda_update_prompt deactivate
else
return $status
end
end
# return
end

anaconda的fish shell支持的更多相关文章

  1. Fish Shell

    今天看到阮一峰同学的一篇博客(Fish shell 入门教程),讲述的非常详细.清楚,有兴趣的可以直接转去查看此文,本文仅提供一下个人使用心得. 一.fish shell 想必接触过类unix(包括w ...

  2. fish shell 下gopath的设置问题

    GOPATH可以设置多个工程目录,linux下用冒号分隔(必须用冒号,fish shell的空格分割会出错),windows下用分号分隔,但是go get 只会下载pkg到第一个目录,但是编译的时候会 ...

  3. Linux Shell管道调用用户定义函数(使shell支持map函数式特性)

    Linux中有一个管道的概念,常用来流式的处理文本内容,比如一个文件对其中的每一行应用好几个操作,出于两个方面的考虑可能需要在管道中使用用户定义函数: 1. 刚需: 内置的sed/awk之类的可能没法 ...

  4. fish shell version

    如果你使用 fish shell, 想要自己定义变量,或者函数,或者alias, 不要使用      version     这个名字, 因为,version 这个名字 被 fish 本身占了.... ...

  5. Mac开发必备工具(三)—— Fish shell

    Fish shell 简介 fish 可以根据输入自动匹配历史命令.它的一大特点是开箱即用,没有zsh那些繁琐的配置.官网:http://www.fishshell.com/. 安装与配置 在终端里使 ...

  6. Fish Shell使用心得

    Fish的官网宣传语是 Finally, a command line shell for the 90s. 翻译过来就是 Fish shell 是一个为90后准备的 shell. 有人说:" ...

  7. fish shell 自动补全子命令

    之前在 「创建 fish shell 自动补全文件」 中介绍了如何创建 fish 的补全文件,实现对命令的友好补全提示.通过形如 complete -c <command> -a [&qu ...

  8. Mac安装fish shell

    1.brew update 2.brew install fish 3.sudo vi /etc/shells 增加内容:/usr/local/bin/fish   ##增加fish到shell环境变 ...

  9. 在 Ubuntu16.04上安装anaconda+Spyder+TensorFlow(支持GPU)

    TensorFlow 官方文档中文版 http://www.tensorfly.cn/tfdoc/get_started/introduction.html https://zhyack.github ...

随机推荐

  1. Java中的双重检查锁(double checked locking)

    最初的代码 在最近的项目中,写出了这样的一段代码 private static SomeClass instance; public SomeClass getInstance() { if (nul ...

  2. vue框架-学习记录

    前段时间在做vue项目时,遇到挺多问题,想简单总结一下: 1.关于父组件,子组件的通信 网上有很多这方面的讲解,讲解也比较细致,我主要总结了自己在项目中需要的: [1]父组件-子组件 也就是" ...

  3. eslint规则

    碰到eslint报错, 把错误的提示拷贝在这里Ctrl + F找到复制到eslint.js里面就行了. "off"或者0,不启用这个规则 "warn"或者1,出 ...

  4. 重绘(redraw或repaint),重排(reflow)

    浏览器运行机制图: 浏览器的运行机制:layout:布局: 1.构建DOM树(parse):渲染引擎解析HTML文档,首先将标签转换成DOM树中的DOM node(包括js生成的标签)生成内容树(Co ...

  5. Nginx下编译PHP+Mysql

    先说一下PHP在Apache和Nginx下所扮演的角色 apache一般是把php当做自己的一个模块来启动的. 而nginx则是把http请求变量(如get,user_agent等)转发给 php进程 ...

  6. 《android开发艺术探索》读书笔记(十一)--Android的线程和线程池

    接上篇<android开发艺术探索>读书笔记(十)--Android的消息机制 No1: 在Android中可以扮演线程角色的有很多,比如AsyncTask.IntentService.H ...

  7. numpy模块中的sum(axis)方法

    1.sum函数声明 sum(a, axis=None, dtype=None, out=None, keepdims=<class 'numpy._globals._NoValue'>) ...

  8. C. Vasya and String

    原题链接 C. Vasya and String High school student Vasya got a string of length n as a birthday present. T ...

  9. react-native入坑随笔(持续更新中)

    一.问题: 解决方案:删除./node_modules/react-native/local-cli/core/__fixtures__/files/package.json,删除前记得备份. 二.在 ...

  10. sparklyr包:实现Spark与R的接口+sparklyr 0.5

    本文转载于雪晴数据网 相关内容: sparklyr包:实现Spark与R的接口,会用dplyr就能玩Spark Sparklyr与Docker的推荐系统实战 R语言︱H2o深度学习的一些R语言实践-- ...