From a253a72658bc7df220f0cde17a60020efedc4438 Mon Sep 17 00:00:00 2001 From: Diogo Autilio Date: Wed, 11 Jan 2017 01:56:29 -0200 Subject: [PATCH] Add rbenv segment --- config.py.dist | 3 +++ segments/rbenv.py | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 segments/rbenv.py diff --git a/config.py.dist b/config.py.dist index a1e76272..55e894c4 100644 --- a/config.py.dist +++ b/config.py.dist @@ -13,6 +13,9 @@ SEGMENTS = [ # Show current virtual environment (see http://www.virtualenv.org/) 'virtual_env', +# Show current ruby environment (see http://rbenv.org/) + 'rbenv', + # Show the current user's username as in ordinary prompts 'username', diff --git a/segments/rbenv.py b/segments/rbenv.py new file mode 100644 index 00000000..70e34a81 --- /dev/null +++ b/segments/rbenv.py @@ -0,0 +1,13 @@ +import subprocess + + +def add_rbenv_segment(powerline): + try: + p1 = subprocess.Popen(["rbenv", "local"], stdout=subprocess.PIPE) + version = p1.communicate()[0].decode("utf-8").rstrip() + if len(version) <= 0: + return + + powerline.append(' %s ' % version, Color.VIRTUAL_ENV_FG, Color.VIRTUAL_ENV_BG) + except OSError: + return