def add_hostname_segment(): if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = ' %s ' % hostname.split('.')[0] if os.getenv('SSH_CLIENT'): powerline.append(host_prompt, Color.SSH_FG, Color.SSH_BG) else: powerline.append(host_prompt, FG, BG) else: if powerline.args.shell == 'bash': host_prompt = ' \\h ' elif powerline.args.shell == 'zsh': host_prompt = ' %m ' else: import socket host_prompt = ' %s ' % socket.gethostname().split('.')[0] if os.getenv('SSH_CLIENT'): powerline.append(host_prompt, Color.SSH_FG, Color.SSH_BG) else: powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_hostname_segment(): if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = ' %s' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG) else: #if powerline.args.shell == 'bash': # host_prompt = ' \\h' #elif powerline.args.shell == 'zsh': if powerline.args.shell == 'zsh': host_prompt = ' %m' else: import socket #host_prompt = ' %s' % socket.gethostname().split('.')[0] host_prompt = ' %s' % (socket.gethostname().split('.')[0].replace('%s-' % os.getenv('USERNAME'), '')) known_hosts = {'sunrise-E49': 'sunrise'} if host_prompt.strip() in known_hosts: host_prompt = known_hosts[host_prompt.strip()] powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_hostname_segment(): if os.getenv('SSH_CLIENT'): host_prompt = u' \uE0A2' else: host_prompt = '' if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt += ' %s' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG) else: if powerline.args.shell == 'bash': host_prompt += ' \\h' elif powerline.args.shell == 'zsh': host_prompt += ' %m' else: import socket host_prompt += ' %s' % socket.gethostname().split('.')[0] powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_userhost_segment(powerline): import os if powerline.args.shell == 'bash': user_prompt = ' \\u' elif powerline.args.shell == 'zsh': user_prompt = ' %n' else: user_prompt = ' %s' % os.getenv('USER') if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = '%s ' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG) else: if powerline.args.shell == 'bash': host_prompt = '\\h ' elif powerline.args.shell == 'zsh': host_prompt = '%m ' else: import socket host_prompt = '%s ' % socket.gethostname().split('.')[0] if os.getenv('USER') == 'root': bgcolor = Color.USERNAME_ROOT_BG else: bgcolor = Color.USERHOST_BG powerline.append(user_prompt + "@" + host_prompt, Color.USERHOST_FG, bgcolor)
def add_hostname_segment(): if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = ' %s' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG) else: #if powerline.args.shell == 'bash': # host_prompt = ' \\h' #elif powerline.args.shell == 'zsh': if powerline.args.shell == 'zsh': host_prompt = ' %m' else: import socket #host_prompt = ' %s' % socket.gethostname().split('.')[0] host_prompt = ' %s' % (socket.gethostname().split('.')[0].replace( '%s-' % os.getenv('USERNAME'), '')) known_hosts = {'sunrise-E49': 'sunrise'} if host_prompt.strip() in known_hosts: host_prompt = known_hosts[host_prompt.strip()] powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_hostname_segment(): from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = ' %s' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG)
def add_hostname_segment(): if powerline.args.colorize_hostname: from lib.color_compliment import string_to_hash_to_color_and_opposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() fg, bg = string_to_hash_to_color_and_opposite(hostname) fg, bg = (rgb2short(*color) for color in [fg, bg]) host_prompt = ' %s ' % hostname.split('.')[0] powerline.append(host_prompt, fg, bg) else: if powerline.args.shell == 'bash': host_prompt = ' \\h ' elif powerline.args.shell == 'zsh': host_prompt = ' %m ' else: import socket host_prompt = ' %s ' % socket.gethostname().split('.')[0] powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_hostname_segment(powerline): from socket import gethostname hostname = gethostname() if hostname != powerline.args.default_host: if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = ' %s ' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG) else: if powerline.args.shell == 'bash': host_prompt = ' \\h ' elif powerline.args.shell == 'zsh': host_prompt = ' %m ' else: import socket host_prompt = ' %s ' % socket.gethostname().split('.')[0] powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_hostname_segment(): if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = " %s " % hostname.split(".")[0] powerline.append(host_prompt, FG, BG) else: if powerline.args.shell == "bash": host_prompt = " \\h " elif powerline.args.shell == "zsh": host_prompt = " %m " else: import socket host_prompt = " %s " % socket.gethostname().split(".")[0] powerline.append(host_prompt, Color.HOSTNAME_FG, Color.HOSTNAME_BG)
def add_myunameandhost_segment(): import os if powerline.args.colorize_hostname: from lib.color_compliment import stringToHashToColorAndOpposite from lib.colortrans import rgb2short from socket import gethostname hostname = gethostname() FG, BG = stringToHashToColorAndOpposite(hostname) FG, BG = (rgb2short(*color) for color in [FG, BG]) host_prompt = '%s ' % hostname.split('.')[0] powerline.append(host_prompt, FG, BG) else: if powerline.args.shell == 'bash': host_prompt = '\\h ' elif powerline.args.shell == 'zsh': host_prompt = '%m ' else: import socket host_prompt = '%s ' % socket.gethostname().split('.')[0] if powerline.args.shell == 'bash': user_prompt = ' \\u' elif powerline.args.shell == 'zsh': user_prompt = ' %n' else: user_prompt = ' %s' % os.getenv('USER') if os.getenv('USER') == 'root': bgcolor = Color.USERNAME_ROOT_BG else: bgcolor = Color.USERNAME_BG powerline.append(user_prompt+'@'+host_prompt, Color.USERNAME_FG, bgcolor)