Skip to content

Instantly share code, notes, and snippets.

@ruiwen
Last active December 23, 2015 03:19
Show Gist options
  • Select an option

  • Save ruiwen/6572372 to your computer and use it in GitHub Desktop.

Select an option

Save ruiwen/6572372 to your computer and use it in GitHub Desktop.
Sample .tmux.conf and other scripts Add these to your $HOME in the appropriate places and shown in their filenames
#!/bin/bash -f
# Obtained from http://superuser.com/a/433702
currentwindow=`tmux list-window | tr '\t' ' ' | sed -n -e '/(active)/s/^[^:]*: *\([^ ]*\) .*/\1/gp'`;
currentpane=`tmux list-panes | sed -n -e '/(active)/s/^\([^:]*\):.*/\1/gp'`;
panecount=`tmux list-panes | wc | sed -e 's/^ *//g' -e 's/ .*$//g'`;
inzoom=`echo $currentwindow | sed -n -e '/^zoom/p'`;
if [ $panecount -ne 1 ]; then
inzoom="";
fi
if [ $inzoom ]; then
lastpane=`echo $currentwindow | rev | cut -f 1 -d '@' | rev`;
lastwindow=`echo $currentwindow | cut -f 2- -d '@' | rev | cut -f 2- -d '@' | rev`;
tmux select-window -t $lastwindow;
tmux select-pane -t $lastpane;
tmux swap-pane -s $currentwindow;
tmux kill-window -t $currentwindow;
else
newwindowname=zoom@$currentwindow@$currentpane;
tmux new-window -d -n $newwindowname;
tmux swap-pane -s $newwindowname;
tmux select-window -t $newwindowname;
fi
# $Id: screen-keys.conf,v 1.6 2010/02/02 21:34:16 nicm Exp $
#
# By Nicholas Marriott. Public domain.
#
# This configuration file binds many of the common GNU screen key bindings to
# appropriate tmux key bindings. Note that for some key bindings there is no
# tmux analogue and also that this set omits binding some commands available in
# tmux but not in screen.
#
# Note this is only a selection of key bindings and they are in addition to the
# normal tmux key bindings. This is intended as an example not as to be used
# as-is.
# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix
# screen ^C c
unbind ^C
bind ^C new-window
unbind c
bind c new-window
# detach ^D d
unbind ^D
bind ^D detach
# displays *
unbind *
bind * list-clients
#kill pane
unbind x
bind x kill-pane
# title A
unbind A
bind A command-prompt "rename-window %%"
# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows
# kill K k
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"
# redisplay ^L l
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client
# split -v |
unbind |
bind | split-window -h
unbind -
bind - split-window -v
# zoom
unbind +
bind + run ". ~/.tmux/zoom"
# " windowlist -b
unbind '"'
bind '"' choose-window
# Below from https://mutelight.org/practical-tmux
# start window numbering at 1
set -g base-index 1
# start pane numbering at 1
set -g pane-base-index 1
# Faster command sequences
set -s escape-time 100
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity on
# quick pane cycling
unbind ^A
bind ^A select-pane -t :.+
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# Set status bar
set -g status-bg '#333333'
set -g status-fg yellow
set -g status-attr bold
#set -g status-left ""
#set -g status-right "#[fg=green]#H"
# Highlight active window
set-window-option -g window-status-current-bg '#bbbbbb'
set-window-option -g window-status-current-fg red
set-window-option -g window-status-attr bold
# Pane number display
set-option -g display-panes-active-colour yellow
set-option -g display-panes-colour colour166
# vi keys in copy mode
set -g mode-keys vi
# mouse select
#set -g mouse-select-pane on
setw -g mode-mouse on
set-option -g mouse-select-pane on
# Resize
bind-key -r Up resize-pane -U
bind-key -r Down resize-pane -D
bind-key -r Left resize-pane -L
bind-key -r Right resize-pane -R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment