Adding an SSH segment

This commit is contained in:
Xfennec 2013-11-13 18:25:51 +01:00
parent 60cf330b8c
commit 837ad970fa
4 changed files with 18 additions and 0 deletions

View file

@ -16,6 +16,9 @@ SEGMENTS = [
# Show the machine's hostname. Mostly used when ssh-ing into other machines
'hostname',
# Show a padlock when ssh-ing from another machine
'ssh',
# Show the current directory. If the path is too long, the middle part is
# replaced with ellipsis ('...')
'cwd',

View file

@ -12,16 +12,19 @@ class Powerline:
symbols = {
'compatible': {
'lock': 'RO',
'network': 'SSH',
'separator': u'\u25B6',
'separator_thin': u'\u276F'
},
'patched': {
'lock': u'\uE0A2',
'network': u'\uE0A2',
'separator': u'\uE0B0',
'separator_thin': u'\uE0B1'
},
'flat': {
'lock': '',
'network': '',
'separator': '',
'separator_thin': ''
},
@ -40,6 +43,7 @@ class Powerline:
self.color_template = self.color_templates[shell]
self.reset = self.color_template % '[0m'
self.lock = Powerline.symbols[mode]['lock']
self.network = Powerline.symbols[mode]['network']
self.separator = Powerline.symbols[mode]['separator']
self.separator_thin = Powerline.symbols[mode]['separator_thin']
self.segments = []

8
segments/ssh.py Normal file
View file

@ -0,0 +1,8 @@
import os
def add_ssh_segment():
if os.getenv('SSH_CLIENT'):
powerline.append(' %s ' % powerline.network, Color.SSH_FG, Color.SSH_BG)
add_ssh_segment()

View file

@ -20,6 +20,9 @@ class DefaultColor:
READONLY_BG = 124
READONLY_FG = 254
SSH_BG = 166 # medium orange
SSH_FG = 254
REPO_CLEAN_BG = 148 # a light green color
REPO_CLEAN_FG = 0 # black
REPO_DIRTY_BG = 161 # pink/red