add new segment for gsnws

Change-Id: Ic69e7eef0a216266b7af15961027b6be047480a3
This commit is contained in:
Jialun Zhao 2017-12-14 15:58:12 +08:00
parent 9ef3675056
commit 9ff3fddd11
3 changed files with 27 additions and 5 deletions

View file

@ -15,11 +15,6 @@ def replace_home_dir(cwd):
def replace_gsnws_root_dir(cwd):
gsnws = os.path.realpath(os.getenv('GSN_WS_ROOT'))
if cwd.startswith(gsnws):
pat_match = re.match('^\w{7}__ndpgsn_5_0_(?:wb__ndpgsn_5_0_(\w+)|(\w+))$', os.getenv('GSN_WS_NAME'))
if pat_match.group(1):
return pat_match.group(1) + cwd[len(gsnws):]
if pat_match.group(2):
return pat_match.group(2) + cwd[len(gsnws):]
return '$GSN_WS_ROOT' + cwd[len(gsnws):]
return cwd

View file

@ -0,0 +1,24 @@
import re
import os
from ..utils import BasicSegment
def get_gsnws_name():
pat_match = re.match('^\w{7}__ndpgsn_5_0_(?:wb__ndpgsn_5_0_(\w+)|(\w+))$', os.getenv('GSN_WS_NAME'))
if pat_match.group(1):
return pat_match.group(1)
if pat_match.group(2):
return pat_match.group(2)
return gsnws
class Segment(BasicSegment):
def add_to_powerline(self):
if not os.getenv('GSN_WS_NAME'):
pass
else:
gsnws = get_gsnws_name()
bg = self.powerline.theme.GSNWS_BG
fg = self.powerline.theme.GSNWS_FG
self.powerline.append(" " + gsnws + " ", fg, bg)

View file

@ -39,3 +39,6 @@ class Color(DefaultColor):
AWS_PROFILE_FG = 7
AWS_PROFILE_BG = 2
GSNWS_BG = 4
GSNWS_FG = 7