From 504e212f147cc8a82a0e8ada7c40da93535847c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Silkeb=C3=A6kken?= Date: Tue, 22 Jan 2013 14:19:04 +0100 Subject: [PATCH] Add common virtualenv segment --- powerline/config_files/colorschemes/shell/default.json | 4 +++- powerline/config_files/themes/shell/default.json | 3 +++ powerline/config_files/themes/shell/default_leftonly.json | 3 +++ powerline/segments/common.py | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/powerline/config_files/colorschemes/shell/default.json b/powerline/config_files/colorschemes/shell/default.json index 7fb4bc64..6c744f8a 100644 --- a/powerline/config_files/colorschemes/shell/default.json +++ b/powerline/config_files/colorschemes/shell/default.json @@ -1,5 +1,5 @@ { - "name": "Default color scheme for terminal prompts", + "name": "Default color scheme for shell prompts", "colors": { "black": 16, "white": 231, @@ -10,6 +10,7 @@ "brightgreen": 148, "darkestcyan": 23, + "darkcyan": 74, "mediumcyan": 117, "brightcyan": 159, @@ -55,6 +56,7 @@ "groups": { "user": { "fg": "white", "bg": "darkblue", "attr": ["bold"] }, "superuser": { "fg": "white", "bg": "brightred", "attr": ["bold"] }, + "virtualenv": { "fg": "white", "bg": "darkcyan" }, "branch": { "fg": "gray9", "bg": "gray2" }, "cwd": { "fg": "gray9", "bg": "gray4" }, "cwd:current_folder": { "fg": "gray10", "bg": "gray4", "attr": ["bold"] }, diff --git a/powerline/config_files/themes/shell/default.json b/powerline/config_files/themes/shell/default.json index 24712023..00d81e28 100644 --- a/powerline/config_files/themes/shell/default.json +++ b/powerline/config_files/themes/shell/default.json @@ -9,6 +9,9 @@ { "name": "user" }, + { + "name": "virtualenv" + }, { "name": "cwd", "args": { diff --git a/powerline/config_files/themes/shell/default_leftonly.json b/powerline/config_files/themes/shell/default_leftonly.json index 5d7c6fca..95d09443 100644 --- a/powerline/config_files/themes/shell/default_leftonly.json +++ b/powerline/config_files/themes/shell/default_leftonly.json @@ -9,6 +9,9 @@ { "name": "user" }, + { + "name": "virtualenv" + }, { "name": "branch", "before": " " diff --git a/powerline/segments/common.py b/powerline/segments/common.py index 9a4b770a..8cd43503 100644 --- a/powerline/segments/common.py +++ b/powerline/segments/common.py @@ -211,3 +211,7 @@ def network_load(interface='eth0', measure_interval=1, suffix='B/s', binary_pref rx_diff=humanize_bytes((b2[0] - b1[0]) / measure_interval, suffix, binary_prefix), tx_diff=humanize_bytes((b2[1] - b1[1]) / measure_interval, suffix, binary_prefix), ) + + +def virtualenv(): + return os.path.basename(os.environ.get('VIRTUAL_ENV', '')) or None