Update tmux theme and add sourceable config file

The tmux theme has been updated and now matches the other themes much
better. It may still look a little boring and segment cropping isn't
enabled, but it's a good starting point. It colors the weather segment
differently based on the current weather and temperature, and some other
segment colors have been tweaked.

To enable the theme, add the following to your tmux.conf:

    source '/full/path/to/powerline/bindings/tmux/powerline.conf'

Closes #51.
This commit is contained in:
Kim Silkebækken 2013-01-22 16:36:50 +01:00
parent 96760675ea
commit 8f055473ac
5 changed files with 94 additions and 40 deletions

View File

@ -0,0 +1,11 @@
set -g status on
set -g status-utf8 on
set -g status-interval 2
set -g status-fg colour231
set -g status-bg colour234
set -g status-left-length 20
set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]#(powerline-tmux left)'
set -g status-right '#(powerline-tmux right)'
set -g status-right-length 150
set -g window-status-format "#[fg=colour244,bg=colour234]#I #[fg=colour240] #[fg=colour249]#W "
set -g window-status-current-format "#[fg=colour234,bg=colour31]#[fg=colour117,bg=colour31] #I  #[fg=colour231,bold]#W #[fg=colour31,bg=colour234,nobold]"

View File

@ -10,21 +10,46 @@
"brightblue": 117,
"brightestblue": 153,
"green": 148,
"yellow": 220,
"red": 202
"gray0": 234,
"gray1": 235,
"gray2": 236,
"gray3": 239,
"gray4": 240,
"gray5": 241,
"gray6": 244,
"gray7": 245,
"gray8": 247,
"gray9": 250,
"gray10": 254,
"system_load_good": 106,
"system_load_bad": 178,
"system_load_ugly": 202,
"weather_temp_cold": 67,
"weather_temp_hot": 166,
"weather_condition_cold": 117,
"weather_condition_hot": 228
},
"groups": {
"user": { "fg": "white", "bg": "mediumblue", "attr": ["bold"] },
"date": { "fg": "white", "bg": "mediumblue" },
"weather": { "fg": "brightestblue", "bg": "darkblue" },
"network_load": { "fg": "brightestblue", "bg": "darkblue" },
"external_ip": { "fg": "brightestblue", "bg": "darkblue" },
"system_load": { "fg": "brightblue", "bg": "darkestblue" },
"system_load_good": { "fg": "green", "bg": "darkestblue" },
"system_load_bad": { "fg": "yellow", "bg": "darkestblue" },
"system_load_ugly": { "fg": "red", "bg": "darkestblue" },
"cpu_load_percent": { "fg": "brightblue", "bg": "darkestblue" },
"uptime": { "fg": "brightblue", "bg": "darkestblue" }
"background:divider": { "fg": "gray5", "bg": "gray0" },
"session": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
"date": { "fg": "gray8", "bg": "gray2" },
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
"time:divider": { "fg": "gray5", "bg": "gray2" },
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
"weather": { "fg": "gray8", "bg": "gray0" },
"weather_temp_cold": { "fg": "weather_temp_cold", "bg": "gray0" },
"weather_temp_hot": { "fg": "weather_temp_hot", "bg": "gray0" },
"weather_condition_☼": { "fg": "weather_condition_hot", "bg": "gray0" },
"weather_condition_❅": { "fg": "weather_condition_cold", "bg": "gray0" },
"weather_condition_☔": { "fg": "weather_condition_cold", "bg": "gray0" },
"uptime": { "fg": "gray8", "bg": "gray0" },
"external_ip": { "fg": "gray8", "bg": "gray0" },
"network_load": { "fg": "gray8", "bg": "gray0" },
"system_load": { "fg": "gray8", "bg": "gray0" },
"system_load_good": { "fg": "system_load_good", "bg": "gray0" },
"system_load_bad": { "fg": "system_load_bad", "bg": "gray0" },
"system_load_ugly": { "fg": "system_load_ugly", "bg": "gray0" }
}
}

View File

@ -4,7 +4,10 @@
"left": [
{
"name": "hostname",
"before": " "
"before": " ",
"args": {
"only_if_ssh": true
}
},
{
"name": "user"

View File

@ -1,42 +1,46 @@
{
"default_module": "powerline.segments.common",
"segments": {
"left": [
"right": [
{
"name": "user"
"name": "uptime",
"before": "⇑ ",
"priority": 50,
"divider_highlight_group": "background:divider"
},
{
"name": "external_ip",
"before": "ⓦ "
"before": "ⓦ ",
"priority": 50,
"divider_highlight_group": "background:divider"
},
{
"name": "network_load"
"name": "network_load",
"priority": 50,
"divider_highlight_group": "background:divider"
},
{
"name": "uptime",
"before": "⇑ "
}
],
"right": [
{
"name": "system_load"
"name": "system_load",
"priority": 50,
"divider_highlight_group": "background:divider"
},
{
"name": "cpu_load_percent"
},
{
"name": "weather"
},
{
"name": "date",
"args": {"format": "%a"}
"name": "weather",
"priority": 50,
"divider_highlight_group": "background:divider"
},
{
"name": "date"
},
{
"name": "date",
"args": {"format": "%H:%M"}
"args": {"format": "%H:%M"},
"before": "⌚ ",
"highlight_group": ["time", "date"],
"divider_highlight_group": "time:divider"
},
{
"name": "hostname"
}
]
}

View File

@ -43,9 +43,9 @@ def _urllib_urlencode(string):
return urllib.urlencode(string)
def hostname():
def hostname(only_if_ssh=False):
import socket
if not os.environ.get('SSH_CLIENT'):
if only_if_ssh and not os.environ.get('SSH_CLIENT'):
return None
return socket.gethostname()
@ -146,7 +146,17 @@ def weather(unit='c', location_query=None):
for icon, codes in weather_conditions_codes.items():
if condition_code in codes:
break
return u'{0} {1}°{2}'.format(icon, condition['temp'], unit.upper())
return [
{
'contents': icon + ' ',
'highlight_group': ['weather_condition_' + icon, 'weather_condition', 'weather'],
},
{
'contents': '{0}°{1}'.format(condition['temp'], unit.upper()),
'highlight_group': ['weather_temp_cold' if int(condition['temp']) < 0 else 'weather_temp_hot', 'weather_temp', 'weather'],
'draw_divider': False,
},
]
def system_load(format='{avg:.1f}', threshold_good=1, threshold_bad=2):
@ -166,6 +176,7 @@ def system_load(format='{avg:.1f}', threshold_good=1, threshold_bad=2):
'highlight_group': [hl, 'system_load'],
'draw_divider': False,
})
ret[0]['draw_divider'] = True
ret[0]['contents'] += ' '
ret[1]['contents'] += ' '
return ret
@ -208,8 +219,8 @@ def network_load(interface='eth0', measure_interval=1, suffix='B/s', binary_pref
time.sleep(measure_interval)
b2 = get_bytes()
return u'{rx_diff}{tx_diff}'.format(
rx_diff=humanize_bytes((b2[0] - b1[0]) / measure_interval, suffix, binary_prefix),
tx_diff=humanize_bytes((b2[1] - b1[1]) / measure_interval, suffix, binary_prefix),
rx_diff=humanize_bytes((b2[0] - b1[0]) / measure_interval, suffix, binary_prefix).rjust(8),
tx_diff=humanize_bytes((b2[1] - b1[1]) / measure_interval, suffix, binary_prefix).rjust(8),
)