Permalink
Browse files

Give a try to tmux powerline

  • Loading branch information...
Herzult committed Oct 1, 2012
1 parent de9b2a3 commit 8795074320284e05d5f35f60e35d5d680bb870a0
Showing with 203 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +2 −0 bash/bashrc
  3. +13 −0 tmux/conf
  4. +1 −0 tmux/powerline
  5. +60 −0 tmux/status-left.sh
  6. +124 −0 tmux/status-right.sh
View
@@ -46,3 +46,6 @@
[submodule "vim/bundle/syntastic"]
path = vim/bundle/syntastic
url = git://github.com/scrooloose/syntastic.git
+[submodule "tmux/powerline"]
+ path = tmux/powerline
+ url = git://github.com/erikw/tmux-powerline.git
View
@@ -21,6 +21,8 @@ prompt() {
fi
PS1="${smiley}${git} \$ "
+
+ PS1="$PS1"'$([ -n "$TMUX" ] && tmux setenv TMUXPWD_$(tmux display -p "#I_#P") "$PWD")'
}
PROMPT_COMMAND=prompt
View
@@ -53,3 +53,16 @@ set -g status-right '%Y-%m-%d | %H:%M '
# status bar options
set-option -g status-justify centre # alignment of windows
set-window-option -g window-status-format ' #W ' # Inactive windows in status bar
+
+#------------------------------------------------------------------------------
+# POWERLINE
+#------------------------------------------------------------------------------
+
+set-option -g status on
+set-option -g status-interval 2
+set-option -g status-utf8 on
+set-option -g status-justify "centre"
+set-option -g status-left-length 90
+set-option -g status-right-length 90
+set-option -g status-left "#(~/.dotfiles/tmux/status-left.sh)"
+set-option -g status-right "#(~/.dotfiles/tmux/status-right.sh)"
Submodule powerline added at ae2c1f
View
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+#Print the status-left for tmux.
+#
+# The powerline root directory.
+cwd=$(dirname $0)/powerline
+
+# Source global configurations.
+source "${cwd}/config.sh"
+
+# Source lib functions.
+source "${cwd}/lib.sh"
+
+segments_path="${cwd}/${segments_dir}"
+
+# Mute this statusbar?
+mute_status_check "left"
+
+# Segments
+
+declare -A tmux_session_info
+tmux_session_info+=(["script"]="${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"
+
+declare -A wan_ip
+wan_ip+=(["script"]="${segments_path}/wan_ip.sh")
+wan_ip+=(["foreground"]="colour255")
+wan_ip+=(["background"]="colour24")
+wan_ip+=(["separator"]="${separator_right_thin}")
+wan_ip+=(["separator_fg"]="white")
+register_segment "wan_ip"
+
+declare -A vcs_branch
+vcs_branch+=(["script"]="${segments_path}/vcs_branch.sh")
+vcs_branch+=(["foreground"]="colour88")
+vcs_branch+=(["background"]="colour29")
+vcs_branch+=(["separator"]="${separator_right_bold}")
+register_segment "vcs_branch"
+
+# Print the status line in the order of registration above.
+print_status_line_left
+
+exit 0
View
@@ -0,0 +1,124 @@
+#!/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.
+
+# The powerline root directory.
+cwd=$(dirname $0)/powerline
+
+# Source global configurations.
+source "${cwd}/config.sh"
+
+# Source lib functions.
+source "${cwd}/lib.sh"
+
+segments_path="${cwd}/${segments_dir}"
+
+# Mute this statusbar?
+mute_status_check "right"
+
+# Segment
+# Comment/uncomment the register function call to enable or disable a segment.
+
+declare -A pwd
+pwd+=(["script"]="${segments_path}/pwd.sh")
+pwd+=(["foreground"]="colour211")
+pwd+=(["background"]="colour89")
+pwd+=(["separator"]="${separator_left_bold}")
+#register_segment "pwd"
+
+declare -A mail_count
+mail_count+=(["script"]="${segments_path}/mail_count_maildir.sh")
+#mail_count+=(["script"]="${segments_path}/mail_count_gmail.sh")
+#mail_count+=(["script"]="${segments_path}/mail_count_apple_mail.sh")
+mail_count+=(["foreground"]="white")
+mail_count+=(["background"]="red")
+mail_count+=(["separator"]="${separator_left_bold}")
+#register_segment "mail_count"
+
+declare -A now_playing
+if [ "$PLATFORM" == "linux" ]; then
+ #now_playing+=(["script"]="${segments_path}/np_mpd.sh")
+ #now_playing+=(["script"]="${segments_path}/np_mpd_simple.sh")
+ #now_playing+=(["script"]="${segments_path}/np_mocp.sh")
+ #now_playing+=(["script"]="${segments_path}/np_spotify_linux_wine.sh")
+ now_playing+=(["script"]="${segments_path}/np_spotify_linux_native.sh")
+ #now_playing+=(["script"]="${segments_path}/np_rhythmbox.sh")
+ #now_playing+=(["script"]="${segments_path}/np_banshee.sh")
+ #now_playing+=(["script"]="${segments_path}/np_audacious.sh")
+elif [ "$PLATFORM" == "mac" ]; then
+ now_playing+=(["script"]="${segments_path}/np_itunes_mac.sh")
+fi
+if [[ ${now_playing["script"]} ]]; then
+ now_playing+=(["foreground"]="colour37")
+ now_playing+=(["background"]="colour234")
+ now_playing+=(["separator"]="${separator_left_bold}")
+ register_segment "now_playing"
+fi
+
+declare -A cpu
+cpu+=(["script"]="${segments_path}/cpu.sh")
+cpu+=(["foreground"]="colour136")
+cpu+=(["background"]="colour240")
+cpu+=(["separator"]="${separator_left_bold}")
+#register_segment "cpu"
+
+declare -A load
+load+=(["script"]="${segments_path}/load.sh")
+load+=(["foreground"]="colour167")
+load+=(["background"]="colour237")
+load+=(["separator"]="${separator_left_bold}")
+#register_segment "load"
+
+declare -A battery
+if [ "$PLATFORM" == "mac" ]; then
+ battery+=(["script"]="${segments_path}/battery_mac.sh")
+else
+ battery+=(["script"]="${segments_path}/battery.sh")
+fi
+battery+=(["foreground"]="colour127")
+battery+=(["background"]="colour137")
+battery+=(["separator"]="${separator_left_bold}")
+register_segment "battery"
+
+declare -A weather
+weather+=(["script"]="${segments_path}/weather.sh")
+weather+=(["foreground"]="colour255")
+weather+=(["background"]="colour37")
+weather+=(["separator"]="${separator_left_bold}")
+#register_segment "weather"
+
+declare -A xkb_layout
+if [ "$PLATFORM" == "linux" ]; then
+ xkb_layout+=(["script"]="${segments_path}/xkb_layout.sh")
+ xkb_layout+=(["foreground"]="colour117")
+ xkb_layout+=(["background"]="colour125")
+ xkb_layout+=(["separator"]="${separator_left_bold}")
+fi
+#register_segment "xkb_layout"
+
+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"
+
+# Print the status line in the order of registration above.
+print_status_line_right
+
+exit 0

0 comments on commit 8795074

Please sign in to comment.