Parcourir la source

start moving to powerline customisation in `.config/powerline`

Weiyi Lou il y a 12 ans
Parent
commit
ad792743f3

+ 0 - 17
tmux/tmux-powerline-custom/config.sh

@@ -1,17 +0,0 @@
-#!/bin/sh
-# Cofigurations for tmux-powerline.
-
-if [ -z "$PLATFORM" ]; then
-  UNAME=$(uname)
-  if [ $UNAME == 'Linux' ]; then
-    export PLATFORM="linux"
-  fi
-  if [ $UNAME == 'Darwin' ]; then
-    export PLATFORM="mac"
-  fi
-fi
-
-if [ -z "$USE_PATCHED_FONT" ]; then
-	# Useage of patched font for symbols. true or false.
-	export USE_PATCHED_FONT="true"
-fi

+ 0 - 6
tmux/tmux-powerline-custom/segments/tmux_session_info.sh

@@ -1,6 +0,0 @@
-#!/usr/bin/env sh
-# Prints tmux session info.
-# Assuems that [ -n "$TMUX"].
-tmux display-message -p 'Session: [#S]'
-
-exit 0

+ 0 - 125
tmux/tmux-powerline-custom/segments/weather.sh

@@ -1,125 +0,0 @@
-#!/bin/bash
-# Prints the current weather in Celsius, Fahrenheits or lord Kelvins. The forecast is cached and updated with a period of $update_period.
-
-# You location. Find a string that works for you by Googling on "weather in <location-string>"
-location='Melbourne, Australia'
-
-# Can be any of {c,f,k}.
-unit="c"
-
-tmp_file="/tmp/tmux-powerline_weather.txt"
-
-get_condition_symbol() {
-	local conditions=$(echo "$1" | tr '[:upper:]' '[:lower:]')
-	case "$conditions" in
-	sunny | "partly sunny" | "mostly sunny")
-		hour=$(date +%H)
-		if [ "$hour" -ge "22" -o "$hour" -le "5" ]; then
-			#echo "☽"
-			echo "☾"
-		else
-			#echo "☀"
-			echo "☼"
-		fi
-		;;
-	"rain and snow" | "chance of rain" | "light rain" | rain | "heavy rain" | "freezing drizzle" | flurries | showers | "scattered showers" | drizzle | "rain showers")
-		#echo "☂"
-		echo "☔"
-		;;
-	snow | "light snow" | "scattered snow showers" | icy | ice/snow | "chance of snow" | "snow showers" | sleet)
-		#echo "☃"
-		echo "❅"
-		;;
-	"partly cloudy" | "mostly cloudy" | cloudy | overcast)
-		echo "☁"
-		;;
-	"chance of storm" | thunderstorm | "chance of tstorm" | storm | "scattered thunderstorms")
-		#echo "⚡"
-		echo "☈"
-		;;
-	dust | fog | smoke | haze | mist)
-		echo "♨"
-		;;
-	windy)
-		echo "⚑"
-		#echo "⚐"
-		;;
-	clear)
-		#echo "☐"
-		echo "✈"	# So clear you can see the aeroplanes! TODO what symbol does best represent a clear sky?
-		;;
-	*)
-		echo "?"
-		;;
-	esac
-}
-
-read_tmp_file() {
-	if [ ! -f "$tmp_file" ]; then
-		return
-	fi
-	IFS_bak="$IFS"
-	IFS=$'\n'
-	lines=($(cat ${tmp_file}))
-	IFS="$IFS_bak"
-	degrees="${lines[0]}"
-	conditions="${lines[1]}"
-}
-
-degrees=""
-if [ -f "$tmp_file" ]; then
-	if [ "$PLATFORM" == "mac" ]; then
-		last_update=$(stat -f "%m" ${tmp_file})
-	else
-		last_update=$(stat -c "%Y" ${tmp_file})
-	fi
-	time_now=$(date +%s)
-	update_period=600
-
-	up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc)
-	if [ "$up_to_date" -eq 1 ]; then
-		read_tmp_file
-	fi
-fi
-
-if [ -z "$degrees" ]; then
-	if [ "$unit" == "k" ]; then
-		search_unit="c"
-	else
-		search_unit="$unit"
-	fi
-	# Convert spaces before using this in the URL.
-	if [ "$PLATFORM" == "mac" ]; then
-		search_location=$(echo "$location" | sed -e 's/[ ]/%20/g')
-	else
-		search_location=$(echo "$location" | sed -e 's/\s/%20/g')
-	fi
-
-	weather_data=$(curl --max-time 4 -s "http://www.google.com/ig/api?weather=${search_location}")
-	if [ "$?" -eq "0" ]; then
-		error=$(echo "$weather_data" | grep "problem_cause\|DOCTYPE");
-		if [ -n "$error" ]; then
-			echo "error"
-			exit 1
-		fi
-		degrees=$(echo "$weather_data" | sed "s|.*<temp_${search_unit} data=\"\([^\"]*\)\"/>.*|\1|")
-		if [ "$PLATFORM" == "mac" ]; then
-			conditions=$(echo $weather_data | xpath //current_conditions/condition/@data 2> /dev/null | grep -oe '".*"' | sed "s/\"//g")
-		else
-			conditions=$(echo "$weather_data" | grep -PZo "<current_conditions>(\\n|.)*</current_conditions>" | grep -PZo "(?<=<condition\sdata=\")([^\"]*)")
-		fi
-		echo "$degrees" > $tmp_file
-		echo "$conditions" >> $tmp_file
-	elif [ -f "$tmp_file" ]; then
-		read_tmp_file
-	fi
-fi
-
-if [ -n "$degrees" ]; then
-	if [ "$unit" == "k" ]; then
-		degrees=$(echo "${degrees} + 273.15" | bc)
-	fi
-	unit_upper=$(echo "$unit" | tr '[cfk]' '[CFK]')
-	condition_symbol=$(get_condition_symbol "$conditions")
-	echo "${condition_symbol} ${degrees}°${unit_upper}"
-fi

+ 0 - 50
tmux/tmux-powerline-custom/status-left.sh

@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-#Print the status-left for tmux.
-
-# custom left/right status and segments
-custom_dir=$(dirname $0)
-
-# The powerline root directory. TODO any other neater way of getting fullpath?
-cd ~/dotfiles/tmux/tmux-powerline
-cwd=$(pwd)
-
-# Source global configurations.
-source "${custom_dir}/config.sh"
-
-# Source lib functions.
-source "${cwd}/lib.sh"
-
-segments_path="${cwd}/${segments_dir}"
-custom_segments_path="${custom_dir}/${segments_dir}"
-
-# Mute this statusbar?
-mute_status_check "left"
-
-# Segments
-
-declare -A tmux_session_info
-tmux_session_info+=(["script"]="${custom_segments_path}/tmux_session_info.sh")
-tmux_session_info+=(["foreground"]="colour234")
-tmux_session_info+=(["background"]="colour148")
-tmux_session_info+=(["separator"]="${separator_right_bold}")
-#tmux_session_info+=(["separator_fg"]="default")
-register_segment "tmux_session_info"
-
-declare -A hostname
-hostname+=(["script"]="${segments_path}/hostname.sh")
-hostname+=(["foreground"]="colour0")
-hostname+=(["background"]="colour33")
-hostname+=(["separator"]="${separator_right_bold}")
-register_segment "hostname"
-
-declare -A lan_ip
-lan_ip+=(["script"]="${segments_path}/lan_ip.sh")
-lan_ip+=(["foreground"]="colour255")
-lan_ip+=(["background"]="colour24")
-lan_ip+=(["separator"]="${separator_right_bold}")
-register_segment "lan_ip"
-
-# Print the status line in the order of registration above.
-print_status_line_left
-
-exit 0

+ 0 - 66
tmux/tmux-powerline-custom/status-right.sh

@@ -1,66 +0,0 @@
-#!/usr/bin/env bash
-# This script prints a string will be evaluated for text attributes (but not shell commands) by tmux. It consists of a bunch of segments that are simple shell scripts/programs that output the information to show. For each segment the desired foreground and background color can be specified as well as what separator to use. The script the glues together these segments dynamically so that if one script suddenly does not output anything (= nothing should be shown) the separator colors will be nicely handled.
-
-# custom left/right status and segments
-custom_dir=$(dirname $0)
-
-# The powerline root directory. TODO any other neater way of getting fullpath?
-cd ~/dotfiles/tmux/tmux-powerline
-cwd=$(pwd)
-
-# Source global configurations.
-source "${custom_dir}/config.sh"
-
-# Source lib functions.
-source "${cwd}/lib.sh"
-
-segments_path="${cwd}/${segments_dir}"
-custom_segments_path="${custom_dir}/${segments_dir}"
-
-# Mute this statusbar?
-mute_status_check "right"
-
-# Segment
-# Comment/uncomment the register function call to enable or disable a segment.
-
-declare -A weather
-weather+=(["script"]="${custom_segments_path}/weather.sh")
-weather+=(["foreground"]="colour255")
-weather+=(["background"]="colour37")
-weather+=(["separator"]="${separator_left_bold}")
-#register_segment "weather"
-
-declare -A date_day
-date_day+=(["script"]="${segments_path}/date_day.sh")
-date_day+=(["foreground"]="colour136")
-date_day+=(["background"]="colour235")
-date_day+=(["separator"]="${separator_left_bold}")
-register_segment "date_day"
-
-declare -A date_full
-date_full+=(["script"]="${segments_path}/date_full.sh")
-date_full+=(["foreground"]="colour136")
-date_full+=(["background"]="colour235")
-date_full+=(["separator"]="${separator_left_thin}")
-date_full+=(["separator_fg"]="default")
-register_segment "date_full"
-
-declare -A time
-time+=(["script"]="${segments_path}/time.sh")
-time+=(["foreground"]="colour136")
-time+=(["background"]="colour235")
-time+=(["separator"]="${separator_left_thin}")
-time+=(["separator_fg"]="default")
-register_segment "time"
-
-declare -A wan_ip
-wan_ip+=(["script"]="${segments_path}/wan_ip.sh")
-wan_ip+=(["foreground"]="colour235")
-wan_ip+=(["background"]="colour136")
-wan_ip+=(["separator"]="${separator_left_bold}")
-register_segment "wan_ip"
-
-# Print the status line in the order of registration above.
-print_status_line_right
-
-exit 0

+ 18 - 19
tmux/tmux.conf

@@ -39,7 +39,7 @@ bind-key -t vi-copy 'v' begin-selection
 bind-key -t vi-copy 'y' copy-selection
 
 # prefix+R to reload the config file
-bind-key C-r source-file ~/.tmux.conf; display-message "tmux.conf reloaded"
+bind-key C-r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded";
 
 # detach client like screen, C-a C-d
 bind-key C-d detach-client
@@ -97,21 +97,20 @@ bind-key X kill-session
 source ~/dotfiles/tmux/tmux-colors-solarized/tmuxcolors-256.conf
 
 # Use powerline plugin
-#
-# suggested method by plugin:
-#source ~/dotfiles/powerline/powerline/bindings/tmux/powerline.conf
-#
-# but we'd rather roll our own not-so-blue-and-annoying color scheme
-set -g status on
-#set -g status-position top
-set -g status-utf8 on
-set -g status-interval 2
-set -g status-justify "centre"
-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#F#[fg=colour249]#W "
-set -g window-status-current-format "#[fg=red,bg=colour234]#[fg=colour231,bg=red]#I #[fg=colour231,bold]#W#[fg=red,bg=colour234,nobold]"
+source ~/dotfiles/powerline/powerline/bindings/tmux/powerline.conf
+
+# we'd rather roll our own not-so-blue-and-annoying color scheme
+# TODO work this into a powerline config in ~/.config/powerline
+#set -g status on
+##set -g status-position top
+#set -g status-utf8 on
+#set -g status-interval 2
+#set -g status-justify "centre"
+#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#F#[fg=colour249]#W "
+#set -g window-status-current-format "#[fg=red,bg=colour234]#[fg=colour231,bg=red]#I #[fg=colour231,bold]#W#[fg=red,bg=colour234,nobold]"