Skip to content

Commit

Permalink
Add a generic python environment segment
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBB committed May 7, 2018
1 parent ca85233 commit 0fb964d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spaceline-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ The cdr can also be a function that returns a name to use.")
;;; Segments requiring optional dependencies
;; ========================================

(defvar conda-env-current-name)
(defvar erc-modified-channels-object)
(defvar erc-track-position-in-mode-line)
(defvar fancy-battery-last-status)
Expand Down Expand Up @@ -584,6 +585,22 @@ enabled."
'face 'spaceline-python-venv
'help-echo "Window purpose")))

(spaceline-define-segment python-env
"The current python env. Works with `pyvenv', `pyenv' and `conda'."
(when (and active (eq 'python-mode major-mode))
(let (name source)
(cond
((bound-and-true-p pyvenv-virtual-env-name)
(setq name pyvenv-virtual-env-name source "pyvenv"))
((bound-and-true-p conda-env-current-name)
(setq name conda-env-current-name source "conda"))
((and (fboundp 'pyenv-mode) (setq name (pyenv-mode-version)))
(setq source "pyenv")))
(when name
(propertize name
'face 'spaceline-python-venv
'help-echo (format "Virtual environment (via %s): %s" source name))))))

(spaceline-define-segment python-pyvenv
"The current python venv. Works with `pyvenv'."
(when (and active
Expand Down

0 comments on commit 0fb964d

Please sign in to comment.