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 ...
随机推荐
- Mac 系统安装 oh my zsh
先来张图感受一下: 安装oh my zsh: 1.克隆这个项目到本地(前提是你得有装git) git clone git://github.com/robbyrussell/oh-my-zsh.git ...
- Treap-平衡树学习笔记
平衡树-Treap学习笔记 最近刚学了Treap 发现这种数据结构真的是--妙啊妙啊~~ 咳咳.... 所以发一发博客,也是为了加深蒟蒻自己的理解 顺便帮助一下各位小伙伴们 切入正题 Treap的结构 ...
- Factorial数列的几种实现方式
斐波那契数列很常见,实现的方法主要有递归,for,栈等,下面给出代码 import java.math.BigInteger; import java.util.Scanner; import jav ...
- Java并发系列[6]----Semaphore源码分析
Semaphore(信号量)是JUC包中比较常用到的一个类,它是AQS共享模式的一个应用,可以允许多个线程同时对共享资源进行操作,并且可以有效的控制并发数,利用它可以很好的实现流量控制.Semapho ...
- 解决java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext这个问题
今天在运行别人的SSH项目时,遇到了这个问题 严重: Exception sending context initialized event to listener instance of class ...
- 数组的toString方法
数组继承了object类的toString方法,数据类型将按照旧的格式打印,例如: int[] luckyNumbers = {2,3,5,7,11,13}; String s = "&qu ...
- 机器学习之支持向量机(二):SMO算法
注:关于支持向量机系列文章是借鉴大神的神作,加以自己的理解写成的:若对原作者有损请告知,我会及时处理.转载请标明来源. 序: 我在支持向量机系列中主要讲支持向量机的公式推导,第一部分讲到推出拉格朗日对 ...
- 4.3 lambda表达式
函数,封装的代码块可以很复杂,也可以很简单.当函数的代码块简单到只有一个表达式,就可以考虑用lambda表达式,也称匿名函数. 1 lambda表达式基础 #首先需要声明一点:lambda是表达式而非 ...
- Eventlog控件的使用
CreateEventSource 已重载. 建立一个能够将事件信息写入到系统的特定日志中的应用程序. Delete 已重载. 移除日志资源. DeleteEventSource 已重载. 从事件日志 ...
- SpringBoot CGLIB AOP解决Spring事务,对象调用自己方法事务失效.
对于像我这种喜欢滥用AOP的程序员,遇到坑也是习惯了,不仅仅是事务,其实只要脱离了Spring容器管理的所有对象,对于SpringAOP的注解都会失效,因为他们不是Spring容器的代理类,Sprin ...