Segment to Print Environment Variables
- Added segment function to powerline.segments.common. - Added test to check return values. - Added default colorschemes for everything but iPython. Ref #477
This commit is contained in:
parent
7ccab8e436
commit
ed65d34e1a
|
@ -12,6 +12,7 @@
|
|||
"cwd:divider": { "fg": "gray7", "bg": "gray4" },
|
||||
"hostname": { "fg": "brightyellow", "bg": "mediumorange" },
|
||||
"exit_fail": { "fg": "white", "bg": "darkestred" },
|
||||
"exit_success": { "fg": "white", "bg": "darkestgreen" }
|
||||
"exit_success": { "fg": "white", "bg": "darkestgreen" },
|
||||
"environment": { "fg": "white", "bg": "darkestgreen" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"cwd:divider": { "fg": "gray61", "bg": "darkgreencopper" },
|
||||
"hostname": { "fg": "oldlace", "bg": "darkgreencopper" },
|
||||
"exit_fail": { "fg": "oldlace", "bg": "red" },
|
||||
"exit_success": { "fg": "oldlace", "bg": "green" }
|
||||
"exit_success": { "fg": "oldlace", "bg": "green" },
|
||||
"environment": { "fg": "oldlace", "bg": "green" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"network_load": { "fg": "gray8", "bg": "gray0" },
|
||||
"network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0" },
|
||||
"system_load": { "fg": "gray8", "bg": "gray0" },
|
||||
"system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0" }
|
||||
"system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0" },
|
||||
"environment": { "fg": "gray8", "bg": "gray0" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
|
||||
"virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10" },
|
||||
"col_current": { "fg": "gray6", "bg": "gray10" },
|
||||
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" }
|
||||
"modified_buffers": { "fg": "brightyellow", "bg": "gray2" },
|
||||
"environment": { "fg": "gray8", "bg": "gray2" }
|
||||
},
|
||||
"mode_translations": {
|
||||
"nc": {
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
"line_current": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
|
||||
"line_current_symbol": { "fg": "gray13", "bg": "lightyellow" },
|
||||
"virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "gray10" },
|
||||
"col_current": { "fg": "azure4", "bg": "lightyellow" }
|
||||
"col_current": { "fg": "azure4", "bg": "lightyellow" },
|
||||
"environment": { "fg": "gray61", "bg": "royalblue5" }
|
||||
},
|
||||
"mode_translations": {
|
||||
"nc": {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"system_load": { "fg": "gray8", "bg": "gray0" },
|
||||
"system_load_good": { "fg": "lightyellowgreen", "bg": "gray0" },
|
||||
"system_load_bad": { "fg": "gold3", "bg": "gray0" },
|
||||
"system_load_ugly": { "fg": "orangered", "bg": "gray0" }
|
||||
"system_load_ugly": { "fg": "orangered", "bg": "gray0" },
|
||||
"environment": { "fg": "gray8", "bg": "gray0" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,16 @@ from collections import namedtuple
|
|||
cpu_count = None
|
||||
|
||||
|
||||
@requires_segment_info
|
||||
def environment(pl, segment_info, variable=None):
|
||||
'''Return the value of any defined environment variable
|
||||
|
||||
:param string variable:
|
||||
The environment variable to return if found
|
||||
'''
|
||||
return segment_info['environ'].get(variable, None)
|
||||
|
||||
|
||||
@requires_segment_info
|
||||
def hostname(pl, segment_info, only_if_ssh=False, exclude_domain=False):
|
||||
'''Return the current hostname.
|
||||
|
|
|
@ -327,6 +327,15 @@ class TestCommon(TestCase):
|
|||
segment_info['environ'].pop('VIRTUAL_ENV')
|
||||
self.assertEqual(common.virtualenv(pl=pl, segment_info=segment_info), None)
|
||||
|
||||
def test_environment(self):
|
||||
pl = Pl()
|
||||
variable = 'FOO';
|
||||
value = 'bar';
|
||||
with replace_env(variable, value) as segment_info:
|
||||
self.assertEqual(common.environment(pl=pl, segment_info=segment_info, variable=variable), value)
|
||||
segment_info['environ'].pop(variable)
|
||||
self.assertEqual(common.environment(pl=pl, segment_info=segment_info, variable=variable), None)
|
||||
|
||||
def test_email_imap_alert(self):
|
||||
# TODO
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue