Skip to content

Instantly share code, notes, and snippets.

@napcs
Created August 15, 2011 19:28
Show Gist options
  • Save napcs/1147532 to your computer and use it in GitHub Desktop.
Save napcs/1147532 to your computer and use it in GitHub Desktop.
My tmux config
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"
# start window index of 1
set-option -g base-index 1
setw -g pane-base-index 1
# sane scrolling
# set-option -g terminal-overrides 'xterm*:smcup@:rmcup@'
# UTF-8
set-option -g status-utf8 on
#supposedly fixes pausing in vim
set-option -sg escape-time 1
set-window-option -g mode-mouse on
set-option -g mouse-select-pane on
set-option -g mouse-resize-pane on
set-option -g mouse-select-window on
# act like vim
set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# # act like GNU screen
unbind C-b
set -g prefix C-a
# Allow C-A a to send C-A to application
bind C-a send-prefix
# Reload key
bind r source-file ~/.tmux.conf
# # look good
set -g default-terminal "screen-256color"
set -g history-limit 5000
setw -g xterm-keys on
# # Rebinding the pane splitting bindings
# unbind % # Remove default bindings since we're replacing
bind | split-window -h
bind - split-window -v
# Open panes in new window
unbind v
unbind n
bind v send-keys " ~/tmux-panes -h" C-m
bind n send-keys " ~/tmux-panes -v" C-m
# # Set window notifications
setw -g monitor-activity on
set -g visual-activity on
# panes
bind-key -r J resize-pane -D 5
bind-key -r K resize-pane -U 5
bind-key -r H resize-pane -L 5
bind-key -r L resize-pane -R 5
set-option -g pane-border-fg green
set-option -g pane-border-bg black
set-option -g pane-active-border-fg white
set-option -g pane-active-border-bg yellow
# statusbar --------------------------------------------------------------
# # default statusbar colors
set-option -g status-fg white
set-option -g status-bg black
set-option -g status-attr default
# # default window title colors
set-window-option -g window-status-fg cyan
set-window-option -g window-status-bg default
set-window-option -g window-status-attr dim
# # active window title colors
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg red
set-window-option -g window-status-current-attr bright
# # command/message line colors
set-option -g message-fg white
set-option -g message-bg black
set-option -g message-attr bright
# # Refresh the status bar every 30 seconds.
set-option -g status-interval 30
# # The status bar itself.
set -g status-justify centre
set -g status-left-length 40
set -g status-left "#[fg=#009900]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-right "#[fg=blue]#(~/battery Discharging) | #[fg=cyan]%d %b %R"
set-option -g display-time 1000
# Reload source file
bind-key r source-file ~/.tmux.conf \; display-message "Configuration reloaded"
# Macros
# Show url in buffer
bind C-o run-shell "open $(tmux show-buffer)"
# Pipe pane to log file
bind-key P pipe-pane -o "cat >>$HOME/#W-tmux.log" \; display-message "Toggled logging to $HOME/#W-tmux.log"
# Maximize and restore panes. Don't switch windows between using these :)
# maximize
unbind Up
bind Up neww -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp
# Restore
unbind Down
bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp
# Sync panes
bind C-s set-window-option synchronize-panes
# OSX Clipboard support
source ~/.tmux.clipboard
bind C-v run "tmux set-buffer $(reattach-to-user-namespace pbpaste); tmux paste-buffer"
bind C-c run "tmux save-buffer - | reattach-to-user-namespace pbcopy"
# Linux clipboard support
bind C-p run "tmux set-buffer \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
bind C-y run "tmux save-buffer - | xclip -i -selection clipboard"
# Clear the current pane AND clear the pane's history
bind C-k send-keys 'C-l'\; clear-history
#!/bin/sh
# This needs to be in the home folder and needs
# to be chmod +x so it runs right.
linux_get_bat ()
{
bf=$(cat $BAT_FULL)
bn=$(cat $BAT_NOW)
BAT=`echo "100 * $bn / $bf" | bc`
echo $BAT
}
freebsd_get_bat ()
{
echo "$(sysctl -n hw.acpi.battery.life)%"
}
# Do with grep and awk unless too hard
# TODO Identify which machine we're on from teh script.
case $(uname -s) in
"Linux")
BATPATH=/sys/class/power_supply/BAT0
STATUS=$BATPATH/status
BAT_FULL=$BATPATH/energy_full
BAT_NOW=$BATPATH/energy_now
if [ "$1" = `cat $STATUS` -o "$1" = "" ]; then
echo $(linux_get_bat)%
fi
;;
"FreeBSD")
STATUS=`sysctl -n hw.acpi.battery.state`
case $1 in
"Discharging")
if [ $STATUS -eq 1 ]; then
freebsd_get_bat
fi
;;
"Charging")
if [ $STATUS -eq 2 ]; then
freebsd_get_bat
fi
;;
"")
freebsd_get_bat
;;
esac
;;
"Darwin")
case $1 in
"Discharging")
ext="No";;
"Charging")
ext="Yes";;
esac
ioreg -c AppleSmartBattery -w0 | \
grep -o '"[^"]*" = [^ ]*' | \
sed -e 's/= //g' -e 's/"//g' | \
sort | \
while read key value; do
case $key in
"MaxCapacity")
export maxcap=$value;;
"CurrentCapacity")
export curcap=$value;;
"ExternalConnected")
if [ "$ext" != "$value" ]; then
exit
fi
;;
"FullyCharged")
if [ "$value" = "Yes" ]; then
exit
fi
;;
esac
if [[ -n "$maxcap" && -n $curcap ]]; then
BAT=`echo "100 * $curcap / $maxcap" | bc`
echo ${BAT}%
exit
fi
done
esac
TMUX_CURRENT_DIR=`pwd`
tmux split-window $1
tmux send-keys "cd $TMUX_CURRENT_DIR;clear" C-m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment