Skip to content

Instantly share code, notes, and snippets.

@dannygarcia
Forked from napcs/.tmux.clipboard
Created August 13, 2012 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannygarcia/3344796 to your computer and use it in GitHub Desktop.
Save dannygarcia/3344796 to your computer and use it in GitHub Desktop.
My tmux config
# remap prefix to Ctrl-a instead of Ctrl-b
unbind C-b
set -g prefix C-a
# Allow C-A a to send C-A to application. Useful for Vim, other apps
bind C-a send-prefix
# Reload the .tmux.conf file with Ctrl-r
bind-key r source-file ~/.tmux.conf \; display-message "Configuration reloaded"
# start window index of 1 instead of 0
set-option -g base-index 1
# Start panes at 1 instead of 0. tmux 1.6 only
setw -g pane-base-index 1
# UTF-8 character support in the status bar
set-option -g status-utf8 on
# Lowers the delay time between the prefix key and other keys - fixes pausing in vim
set-option -sg escape-time 1
# Uncomment these if you'd like to use the mouse for some reason
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
# When in Copy mode, act like vim
set-window-option -g mode-keys vi
# Select panes with Prefix h, j, k, and l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Cycle windows with Ctrl-h and Ctrl-l
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
# look good, but ensure your terminal emulator supports this.
# Recommend iTerm2 on OS X with the xterm-256 profile.
set -g default-terminal "screen-256color"
set -g history-limit 5000
# # Rebinding the pane splitting bindings | and -
bind | split-window -h
bind - split-window -v
# Open pane in same directory. Only works when current pane is at a prompt :(
# Uses the tmux-panes script.
unbind V
unbind H
bind V send-keys " ~/tmux-panes -h" C-m
bind H 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
# Styles the pane borders
set-option -g pane-border-fg green
set-option -g pane-border-bg black
# Styles the active pane border. Helps when you have
# more than two panes.
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 1 second.
set-option -g status-interval 1000
# # The status bar itself.
# Uses the battery script below to display battery remaining
# in the status bar.
set -g status-justify centre
set -g status-left-length 40
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
set -g status-right "#[fg=blue]#(~/battery Discharging) | #[fg=cyan]%d %b %R"
# Time messages remain in the status bar. Lower this number
# if this is too distracting.
set-option -g display-time 4000
# Pipe the current pane to a log file with Shift-H - Press Shift-H again to stop.
bind-key H pipe-pane -o "cat >>$HOME/#W-tmux.log" \; display-message "Toggled logging to $HOME/#W-tmux.log"
# Show url in buffer on osx
bind C-o run-shell "open $(tmux show-buffer)"
# 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 - send what you're typing to other panes.
bind C-s set-window-option synchronize-panes
# OSX Clipboard support
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"
#!/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