mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 15:23:48 -05:00
Add fuzzy conda activate with python version display and conda tree leaves preview
41
Examples.md
41
Examples.md
@@ -23,6 +23,7 @@ Table of Contents
|
|||||||
* [Homebrew Cask](#homebrew-cask)
|
* [Homebrew Cask](#homebrew-cask)
|
||||||
* [DNF](#dnf)
|
* [DNF](#dnf)
|
||||||
* [Flatpak](#flatpak)
|
* [Flatpak](#flatpak)
|
||||||
|
* [Conda](#conda)
|
||||||
* Filesystem navigation
|
* Filesystem navigation
|
||||||
* [Opening files](#opening-files)
|
* [Opening files](#opening-files)
|
||||||
* [Changing directory](#changing-directory)
|
* [Changing directory](#changing-directory)
|
||||||
@@ -1517,6 +1518,46 @@ bindkey '^[f^[u' fzf-flatpak-uninstall-widget #alt-f + alt-u
|
|||||||
zle -N fzf-flatpak-uninstall-widget
|
zle -N fzf-flatpak-uninstall-widget
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Conda
|
||||||
|
|
||||||
|
#### conda-activate (for bash)
|
||||||
|
|
||||||
|
Fuzzy conda environment selection with python version display and `conda tree leaves` preview.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
```sh
|
||||||
|
fzf-conda-activate () {
|
||||||
|
choice=(
|
||||||
|
$(
|
||||||
|
conda env list |
|
||||||
|
sed 's/\*/ /;1,2d' |
|
||||||
|
xargs -I {} bash -c '
|
||||||
|
name_path=( {} );
|
||||||
|
py_version=( $(${name_path[1]}/bin/python --version) );
|
||||||
|
echo ${name_path[0]} ${py_version[1]} ${name_path[1]}
|
||||||
|
' |
|
||||||
|
column -t |
|
||||||
|
fzf --layout=reverse \
|
||||||
|
--info=inline \
|
||||||
|
--border=rounded \
|
||||||
|
--height=40 \
|
||||||
|
--preview-window="right:30%" \
|
||||||
|
--preview-label=" conda tree leaves " \
|
||||||
|
--preview=$'
|
||||||
|
line="{}";
|
||||||
|
line_arr=(${line:1:-1});
|
||||||
|
env_prefix="${line_arr[2]}";
|
||||||
|
conda tree -p "$env_prefix" leaves |
|
||||||
|
perl -F\'[^\\w-_]\' -lae \'print for grep /./, @F;\' |
|
||||||
|
sort
|
||||||
|
'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
[[ -n "$choice" ]] && conda activate "$choice"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### v
|
### v
|
||||||
|
|
||||||
#### Inspired by [v](https://github.com/rupa/v). Opens files in ~/.viminfo
|
#### Inspired by [v](https://github.com/rupa/v). Opens files in ~/.viminfo
|
||||||
|
|||||||
Reference in New Issue
Block a user