mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
add new segment for gsnws
Change-Id: Ic69e7eef0a216266b7af15961027b6be047480a3
This commit is contained in:
parent
9ef3675056
commit
9ff3fddd11
|
|
@ -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
|
||||
|
||||
|
|
|
|||
24
powerline_shell/segments/gsnws.py
Normal file
24
powerline_shell/segments/gsnws.py
Normal 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)
|
||||
|
||||
|
|
@ -39,3 +39,6 @@ class Color(DefaultColor):
|
|||
|
||||
AWS_PROFILE_FG = 7
|
||||
AWS_PROFILE_BG = 2
|
||||
|
||||
GSNWS_BG = 4
|
||||
GSNWS_FG = 7
|
||||
|
|
|
|||
Loading…
Reference in a new issue