anaconda的fish shell支持
最近在用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支持的更多相关文章
- Fish Shell
今天看到阮一峰同学的一篇博客(Fish shell 入门教程),讲述的非常详细.清楚,有兴趣的可以直接转去查看此文,本文仅提供一下个人使用心得. 一.fish shell 想必接触过类unix(包括w ...
- fish shell 下gopath的设置问题
GOPATH可以设置多个工程目录,linux下用冒号分隔(必须用冒号,fish shell的空格分割会出错),windows下用分号分隔,但是go get 只会下载pkg到第一个目录,但是编译的时候会 ...
- Linux Shell管道调用用户定义函数(使shell支持map函数式特性)
Linux中有一个管道的概念,常用来流式的处理文本内容,比如一个文件对其中的每一行应用好几个操作,出于两个方面的考虑可能需要在管道中使用用户定义函数: 1. 刚需: 内置的sed/awk之类的可能没法 ...
- fish shell version
如果你使用 fish shell, 想要自己定义变量,或者函数,或者alias, 不要使用 version 这个名字, 因为,version 这个名字 被 fish 本身占了.... ...
- Mac开发必备工具(三)—— Fish shell
Fish shell 简介 fish 可以根据输入自动匹配历史命令.它的一大特点是开箱即用,没有zsh那些繁琐的配置.官网:http://www.fishshell.com/. 安装与配置 在终端里使 ...
- Fish Shell使用心得
Fish的官网宣传语是 Finally, a command line shell for the 90s. 翻译过来就是 Fish shell 是一个为90后准备的 shell. 有人说:" ...
- fish shell 自动补全子命令
之前在 「创建 fish shell 自动补全文件」 中介绍了如何创建 fish 的补全文件,实现对命令的友好补全提示.通过形如 complete -c <command> -a [&qu ...
- Mac安装fish shell
1.brew update 2.brew install fish 3.sudo vi /etc/shells 增加内容:/usr/local/bin/fish ##增加fish到shell环境变 ...
- 在 Ubuntu16.04上安装anaconda+Spyder+TensorFlow(支持GPU)
TensorFlow 官方文档中文版 http://www.tensorfly.cn/tfdoc/get_started/introduction.html https://zhyack.github ...
随机推荐
- [JSOI2008]最大数maxnumber
[JSOI2008]最大数maxnumber 标签: 线段树 单独队列 题目链接 题解 线段树裸题. 如果一直RE可能是你用的cin/cout. Code #include<cstdio> ...
- img alt与title的区别
前端 alt是图片加载不出来时候,对图片的文本替代 title 是鼠标放在图片上时,对图片的进一步说明 seo 搜索引擎对图片意思的理解主要靠 alt
- Conemu, Msys2 工具整合,提升windows下控制台工作效率
与windows cmd相比较git-bash这类的console工具好用很多,但是git-bash的命令和功能相对简单,功能扩展起来不方便,git-bash本身也是基于msys的. 昨天发现使用Ms ...
- SDK编程之多线程编程
本课中,我们将学习如何进行多线程编程.另外我们还将学习如何在不同的线程间进行通信. 理论:前一课中,我们学习了进程,其中讲到每一个进程至少要有一个主线程.这个线程其实是进程执行的一条线索,除此主线程外 ...
- C++11 左值、右值、右值引用详解
C++11 左值.右值.右值引用详解 左值.右值 在C++11中所有的值必属于左值.右值两者之一,右值又可以细分为纯右值.将亡值. 在C++11中可以取地址的.有名字的就是左值,反之,不能取地址的.没 ...
- Yii的数组助手类
获取值 用原生PHP从一个对象.数组.或者包含这两者的一个复杂数据结构中获取数据是非常繁琐的. 你首先得使用isset 检查 key 是否存在, 然后如果存在你就获取它,如果不存在, 则提供一个默认返 ...
- MFRC522
https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md https://github.com/mxgx ...
- cf B. Mishka and trip (数学)
题意 Mishka想要去一个国家旅行,这个国家共有个城市,城市通过道路形成一个环,即第i个城市和第个城市之间有一条道路,此外城市和之间有一条道路.这个城市中有个首中心城市,中心城市与每个城市(除了 ...
- UVA - 1220 Party at Hali-Bula 树的最大独立集
题意: 给定n个人,存在上下级关系,每个人只有一个上级,求最大独立集.并判断最大独立集是否唯一 思路:d[i][0]表示以i为根的子树中,不选择第i个节点的最大独立集,f[i][0]表示以i为根的子 ...
- nginx笔记5-双机热备原理
1动静分离演示: 将笔记3的Demo改造一下,如图所示: 改造完成后,其实就是在网页上显示一张图片 现在启动Tomcat运行起来,如图: 可以看到图片的请求是请求Tomcat下的图片. 现在,通过把静 ...