Browse Source

add tmux config and broken tmux-powerline setup

Weiyi Lou 13 years ago
parent
commit
9c57aa177c

+ 6 - 0
.gitmodules

@@ -58,3 +58,9 @@
 [submodule "vim/bundle/indentguides"]
 	path = vim/bundle/indentguides
 	url = https://github.com/nathanaelkane/vim-indent-guides.git
+[submodule "tmux/tmux-colors-solarized"]
+	path = tmux/tmux-colors-solarized
+	url = https://github.com/seebi/tmux-colors-solarized.git
+[submodule "tmux/tmux-powerline"]
+	path = tmux/tmux-powerline
+	url = https://github.com/erikw/tmux-powerline.git

+ 4 - 0
RUNME

@@ -74,6 +74,10 @@ ln -s dotfiles/pentadactyl/pentadactylrc ~/.pentadactylrc
 mv ~/.screenrc "$BACKUP_DIR"
 ln -s dotfiles/screen/screenrc ~/.screenrc
 
+# Tmux
+mv ~/.tmux.conf "$BACKUP_DIR"
+ln -s dotfiles/tmux/tmux.conf ~/.tmux.conf
+
 # Nethack
 mv ~/.nethackrc "$BACKUP_DIR"
 ln -s dotfiles/nethack/nethackrc ~/.nethackrc

+ 1 - 0
tmux/tmux-colors-solarized

@@ -0,0 +1 @@
+Subproject commit 3cdcb9a600e86bb9296b08637bc7347ca5634418

+ 1 - 0
tmux/tmux-powerline

@@ -0,0 +1 @@
+Subproject commit 2c67084b536d7fa44e515ef916f71daa057a7ae5

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

@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+#Print the status-left for tmux.
+#
+# The powerline root directory.
+cwd="/Users/acerlouw/dotfiles/tmux/tmux-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

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

@@ -0,0 +1,122 @@
+#!/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="/Users/acerlouw/dotfiles/tmux/tmux-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}/maildir_count.sh")
+#mail_count+=(["script"]="${segments_path}/apple_mail_count.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_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

+ 98 - 0
tmux/tmux.conf

@@ -0,0 +1,98 @@
+# use Ctrl-A as the tmux command prefix instead of Ctrl-B
+unbind C-b
+set-option -g prefix C-a
+
+# start windows from 1
+set-option -g base-index 1
+
+# history scrollback
+set-option -g history-limit 9999999
+
+# act like vim
+set-option -g status-keys vi
+set-window-option -g mode-keys vi # vi keys in copy mode (prefix+[)
+
+# Display a status line message when activity occurs in a window for which the
+# monitor-activity window option is enabled.
+set-option -g visual-activity on
+
+# Resize the window to the size of the smallest session for which it is the
+# current window, rather than the smallest session to which it is attached.
+set-window-option -g aggressive-resize on
+
+
+#######################
+# General Key Bindings
+#######################
+
+# prefix+R to reload the config file
+bind-key C-r source-file ~/.tmux.conf; display-message "tmux.conf reloaded"
+
+# detach client like screen
+bind-key C-d detach-client
+
+# enhance copy mode to use more vim like keys for copying
+bind-key -t vi-copy 'v' begin-selection
+bind-key -t vi-copy 'y' copy-selection
+
+
+###################################
+# Window/Pane/Session Manipulation
+###################################
+
+# Window Movement
+bind-key -r C-h previous-window
+bind-key -r C-l next-window
+bind-key -n M-1 select-window -t 1
+bind-key -n M-2 select-window -t 2
+bind-key -n M-3 select-window -t 3
+bind-key -n M-4 select-window -t 4
+bind-key -n M-5 select-window -t 5
+bind-key -n M-6 select-window -t 6
+bind-key -n M-7 select-window -t 7
+bind-key -n M-8 select-window -t 8
+bind-key -n M-9 select-window -t 9
+bind-key -n M-0 select-window -t 10
+
+# Window Creation/Destruction
+bind-key C-c new-window
+# TODO a better shortcut than `prefix+,` for renaming windows, like prefix+A
+
+# Pane Movement
+bind-key h select-pane -L
+bind-key j select-pane -D
+bind-key k select-pane -U
+bind-key l select-pane -R
+
+# Pane Creation/Destruction
+unbind % # Remove default binding for horizontal split since we’re replacing
+bind-key -n C-\ split-window -h
+bind-key -n C-_ split-window -v
+bind-key C-x kill-pane
+
+# Pane Sychronisation
+bind-key s set -w synchronize-panes
+
+# Session Switching/Destruction
+bind-key C-s choose-session
+bind-key X kill-session
+# TODO a better shortcut than `prefix+$` for renaming sessions
+
+
+########################
+# Visual
+########################
+
+# Use solarized colour palette
+source ~/dotfiles/tmux/tmux-colors-solarized/tmuxcolors-256.conf
+# set-option -g default-terminal "screen-256color"
+
+# tmux-powerline setup
+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 60
+set-option -g status-right-length 90
+set-option -g status-left "#(~/dotfiles/tmux/tmux-powerline-custom/status-left.sh)"
+set-option -g status-right "#(~/dotfiles/tmux/tmux-powerline-custom/status-right.sh)"