From ba91da045c64f1ae469dcec287ef96d753e31e6d Mon Sep 17 00:00:00 2001 From: Nicole O'Connor Date: Fri, 30 Jun 2023 16:18:38 -0700 Subject: [PATCH] add support for conda; i now support two dev frameworky things so lets mention this in the readme too --- README.md | 1 + base/zeesh.zsh | 2 ++ modules/conda.zsh | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 modules/conda.zsh diff --git a/README.md b/README.md index d2ad37a..bc22081 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,5 @@ * Provides a unique syntax for running ssh sessions. You can simply type `command@target-host --args` to run a one shot command on target-host (or `@target-host` to open a full ssh session) * Customizes the prompt according to developer's personal preferences (framework for customization coming soon!) * Automatically updates itself, and is capable of installing itself with just a stub zshrc +* Support for some developer environment tools, such as OPAM and conda * And more, as needed! diff --git a/base/zeesh.zsh b/base/zeesh.zsh index 3ea0a2f..380ea51 100644 --- a/base/zeesh.zsh +++ b/base/zeesh.zsh @@ -1,6 +1,8 @@ #cols=$(stty -a | grep -Po '(?<=columns )\d+' | tr -d "\n") cols=$COLUMNS +setopt prompt_subst + function ticker_message () { if [[ $_zeeshdev_ticker_newlines == 0 ]]; then printf "\r${(l:$cols:: :)A}\r" diff --git a/modules/conda.zsh b/modules/conda.zsh new file mode 100644 index 0000000..3856f50 --- /dev/null +++ b/modules/conda.zsh @@ -0,0 +1,21 @@ +# Note: location of conda can be unpredictable; user is expected to +# run `conda init zsh` as normal then move resulting .zshrc +# modifications to .zshrc.local + +# recommended settings for .condarc: +# auto_assign_base: false +# changeps1: false + +local orig_rprompt="${RPROMPT}" + +function precmd_conda_prompt() { + if [[ -v CONDA_DEFAULT_ENV && "$CONDA_DEFAULT_ENV" != "base" ]]; then + RPROMPT="%{$fg[cyan]%}$CONDA_DEFAULT_ENV %{$reset_color%} ${orig_rprompt}" + else + RPROMPT="${orig_rprompt}" + fi +} + +if (( ${+commands[conda]} )); then + precmd_functions+=precmd_conda_prompt +fi \ No newline at end of file