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

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

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

  1. #
  2. # Conda environment activate / deactivate functions for fish shell v2.2.0+.
  3. #
  4. # Ivan Smirnov (C)
  5. #
  6.  
  7. #
  8. # INSTALL
  9. #
  10. # Source this file from the fish shell to enable activate / deactivate functions.
  11. # In order to automatically load these functions on fish startup, append
  12. #
  13. # source (conda info --root)/bin/conda.fish
  14. #
  15. # to the end of your ~/.config/config.fish file.
  16. #
  17. # USAGE
  18. #
  19. # To activate an environment (via name or path), you can use one of the following:
  20. #
  21. # activate ENV
  22. # conda activate ENV
  23. #
  24. # To deactivate an environment, use one of:
  25. #
  26. # deactivate
  27. # conda deactivate
  28. #
  29. # To make the env name appear on the left side, set an environment variable:
  30. #
  31. # set -gx CONDA_LEFT_PROMPT
  32. #
  33. # To go back to making the env name appear on the right, erase that variable:
  34. #
  35. # set -e CONDA_LEFT_PROMPT
  36.  
  37. # Require version fish v2.+ to be able to use array slices, `else if`
  38. # and $status for command substitutions
  39. if [ (echo (fish -v ^&) | sed 's/^.*version \([0-9]\)\..*$/\1/') -lt ]
  40. echo 'Incompatible fish shell version; please upgrade to v2.0 or higher.'
  41. exit
  42. end
  43.  
  44. function __conda_delete_function
  45. functions -e $argv
  46. if functions -q $argv
  47. functions -e $argv
  48. end
  49. end
  50.  
  51. function __conda_restore_prompt
  52. if functions -q __fish_prompt_orig
  53. __conda_delete_function fish_prompt
  54. functions -c __fish_prompt_orig fish_prompt
  55. functions -e __fish_prompt_orig
  56. end
  57.  
  58. if functions -q __fish_right_prompt_orig
  59. __conda_delete_function fish_right_prompt
  60. functions -c __fish_right_prompt_orig fish_right_prompt
  61. functions -e __fish_right_prompt_orig
  62. end
  63. end
  64.  
  65. function __conda_backup_prompt
  66. functions -e __fish_prompt_orig
  67. if functions -q fish_prompt
  68. functions -c fish_prompt __fish_prompt_orig
  69. functions -e fish_prompt
  70. else
  71. function __fish_prompt_orig
  72. end
  73. end
  74.  
  75. functions -e __fish_right_prompt_orig
  76. if functions -q fish_right_prompt
  77. functions -c fish_right_prompt __fish_right_prompt_orig
  78. functions -e fish_right_prompt
  79. else
  80. function __fish_right_prompt_orig
  81. end
  82. end
  83. end
  84.  
  85. function __conda_echo_env
  86. set_color normal
  87. echo -n '('
  88. set_color -o green
  89. echo -n $CONDA_DEFAULT_ENV
  90. set_color normal
  91. echo -n ') '
  92. end
  93.  
  94. # Inject environment name into fish_right_prompt / fish_prompt
  95. function __conda_update_prompt
  96. if [ (conda '..changeps1') -eq ]
  97. switch $argv[]
  98. case activate
  99. __conda_restore_prompt
  100. __conda_backup_prompt
  101. function fish_prompt
  102. if set -q CONDA_LEFT_PROMPT
  103. __conda_echo_env
  104. end
  105. __fish_prompt_orig
  106. end
  107. function fish_right_prompt
  108. if not set -q CONDA_LEFT_PROMPT
  109. __conda_echo_env
  110. end
  111. __fish_right_prompt_orig
  112. end
  113. case deactivate
  114. __conda_restore_prompt
  115. end
  116. end
  117. end
  118.  
  119. # Convert colon-separated path to a legit fish list
  120. function __conda_set_path
  121. set -gx PATH (echo $argv[] | tr : \n)
  122. end
  123.  
  124. # Calls activate / deactivate functions if the first argument is activate or
  125. # deactivate; otherwise, calls conda-<cmd> and passes the arguments through
  126. function conda
  127. if [ (count $argv) -lt ]
  128. command conda
  129. else
  130. if [ (count $argv) -gt ]
  131. set ARGS $argv[..-]
  132. else
  133. set -e ARGS
  134. end
  135. switch $argv[]
  136. case activate deactivate
  137. eval $argv
  138. case '*'
  139. command conda $argv
  140. end
  141. end
  142. end
  143.  
  144. # Equivalent to bash version of conda activate script
  145. function activate --description 'Activate a conda environment.'
  146. if [ (count $argv) -lt ]
  147. echo 'You need to specify a conda environment.'
  148. return
  149. end
  150.  
  151. # deactivate an environment first if it's set
  152. if set -q CONDA_DEFAULT_ENV
  153. conda '..checkenv' $argv[]
  154. if [ $status = ]
  155. __conda_set_path (conda '..deactivate')
  156. set -e CONDA_DEFAULT_ENV
  157. __conda_update_prompt deactivate
  158. else
  159. return
  160. end
  161. end
  162.  
  163. # try to activate the environment
  164. set -l NEW_PATH (conda '..activate' $argv[])
  165. if [ $status = ]
  166. __conda_set_path $NEW_PATH
  167. if [ (echo $argv[] | grep '/') ]
  168. pushd (dirname $argv[])
  169. set -gx CONDA_DEFAULT_ENV (pwd)/(basename $argv[])
  170. popd
  171. else
  172. set -gx CONDA_DEFAULT_ENV $argv[]
  173. end
  174. __conda_update_prompt activate
  175. else
  176. return $status
  177. end
  178. end
  179.  
  180. # Equivalent to bash version of conda deactivate script
  181. function deactivate --description 'Deactivate the current conda environment.'
  182. if set -q CONDA_DEFAULT_ENV # don't deactivate the root environment
  183. set -l NEW_PATH (conda '..deactivate' $argv[])
  184. if [ $status = ]
  185. __conda_set_path $NEW_PATH
  186. set -e CONDA_DEFAULT_ENV
  187. __conda_update_prompt deactivate
  188. else
  189. return $status
  190. end
  191. end
  192. # return
  193. 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. Selenium+Python进行web自动化测试(Demo+API)

    Selenium官方网站 http://selenium-python.readthedocs.io/ 配置使用环境 下载相应的浏览器驱动, Firefox 是默认的 本文以 chrome 为主 ,放 ...

  2. Java经典编程题50道之十四

    输入某年某月某日,判断这一天是这一年的第几天? public class Example14 {    public static void main(String[] args) {         ...

  3. applicationContext.xml最基本配置文件

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  4. hihoCoder 1523 数组重排2 贪心

    题意:给定一个1-N的排列A1, A2, - AN,每次操作小Hi可以选择一个数,把它放到数组的最左边. 请计算小Hi最少进行几次操作就能使得新数组是递增排列的. 思路:最后的序列是递增的,那么必定满 ...

  5. 《清华梦的粉碎》by王垠

     清华梦的诞生 小时候,妈妈给我一个梦.她指着一个大哥哥的照片对我说,这是爸爸的学生,他考上了清华大学,他是我们中学的骄傲.长大后,你也要进入清华大学读书,为我们家争光.我不知道清华是什么样子,但是我 ...

  6. PHPstudy端口占用的问题

    phpStudy很多同学下好了 用localhost可能不能读取到WWW目录下的文件,这个是因为端口被占用,打开其他选项菜单 =>打开配置文件=>httpd-conf=>修改端口号如 ...

  7. 关于.Net的知识和相关书籍

    a. DBCC DROPCLEANBUFFERS 清空缓存信息b. DBCC FREEPROCCACHE 从过程缓存中删除所有元素2. 引用两个和尚打水的故事,说明平时要注重积累,只有量变达到了才会形 ...

  8. Storm+HBase实时实践

    1.HBase Increment计数器 hbase counter的原理: read+count+write,正好完成,就是讲key的value读出,若存在,则完成累加,再写入,若不存在,则按&qu ...

  9. 关于VS2013调试IIS应用源代码时无法进入断点的问题总结

    调试无法进入断点 前言:今天再次遇到之前调试无法进入断点的问题,本来想不写呢觉得没什么只是又犯了同样的错误,但是我发现这个问题我分析起来还是挺费劲的,我仔细想了想原因, 是因为自己对之前的错误没有进行 ...

  10. 【DDD】领域驱动设计实践 —— 一些问题及想法

    在社区系统的DDD实践过程中,将遇到一些问题和产生的想法记录下来,共讨论. 本文为[DDD]系列文章中的其中一篇,其他内容可参考:使用领域驱动设计思想实现业务系统. 1.dto.model和entit ...