最近在用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. ansible实践-1

      不需要安装客户端,通过sshd去通信 基于模块工作,模块可以由任何语言开发 不仅支持命令行使用模块,也支持编写yaml格式的playbook 支持sudo 有提供UI(浏览器图形化)www.ans ...

  2. Filezilla Server日志文件

    Filezilla Server版本:0.9.41. Filezilla Server日志文件在软件安装目录下Logs目录下. 但Filezilla Server默认不开始日志记录,如何开启filez ...

  3. Spring_Spring与DAO_Spring的Jdbc模板

    一.导入Jar包 二.定义实体类与DB表 public class Student { private Integer id; private String name; private int age ...

  4. Asp.Net Core 基于QuartzNet任务管理系统

    之前一直想搞个后台任务管理系统,零零散散的搞到现在,也算完成了. 这里发布出来,请园里的dalao批评指导! 废话不多说,进入正题. github地址:https://github.com/YANGK ...

  5. Redis进阶实践之十三 Redis的Redis-trib.rb文件详解

    一.简介     事先说明一下,本篇文章不涉及对redis-trib.rb源代码的分析,只是从使用的角度来阐述一下,对第一次使用的人来说很重要.redis-trib.rb是redis官方推出的管理re ...

  6. hdu 1010 回溯加奇偶性剪枝

    普通的剪枝会超时,必须加入奇偶性剪枝. 直接上图: AC代码: #include<cstdio> #include<cstring> #include<algorithm ...

  7. OpenStack中memcached的使用和实现

    概述 主要分享下个人对Liberty版本openstack中cache使用的理解,由于作者水平有限,难免有所错误,疏漏,还望批评指正. openstack中可以使用cache层来缓存数据,Libert ...

  8. tcp/ip 卷一 读书笔记(1)tcp/ip 概述

    TCP/IP协议概述 术语 广域网 WAN 局域网 LAN TCP/IP四层网络模型 TCP/IP通常被认为是一个四层协议系统 网络接口层 包括arp,rarp协议,包括操作系统中的网卡驱动程序和对应 ...

  9. 2015最全iOS开发自学视频资料(基础+实战)

    最全的iOS自学视频,包括c,objective-c,UI等等,没有你找不到的,只有你学不会的,只要你想学,这里都有你所需要的. 推荐教程点这里:http://www.mobiletrain.org/ ...

  10. 2.2 HOST主桥

    本节以MPC8548处理器为例说明HOST主桥在PowerPC处理器中的实现机制,并简要介绍x86处理器系统使用的HOST主桥. MPC8548处理器是Freescale基于E500 V2内核的一个P ...