Skip to content
Browse files

* initial commit

  • Loading branch information...
0 parents commit 6b28b10144cab9992c9723037c3b99956e83a1f0 @brandur brandur committed Jul 21, 2011
Showing with 102 additions and 0 deletions.
  1. +45 −0 .tmux.conf
  2. +57 −0 tmx
45 .tmux.conf
@@ -0,0 +1,45 @@
+#
+# Tmux configuration
+#
+# See:
+# http://github.com/brandur/tmux-extra
+#
+
+# C-b is not acceptable -- Vim uses it
+set-option -g prefix C-a
+bind-key C-a last-window
+
+# Start numbering at 1
+set -g base-index 1
+
+# Allows for faster key repetition
+set -s escape-time 0
+
+# Set status bar
+set -g status-bg black
+set -g status-fg white
+set -g status-left ""
+set -g status-right "#[fg=green]#H"
+
+# Rather than constraining window size to the maximum size of any client
+# connected to the *session*, constrain window size to the maximum size of any
+# client connected to *that window*. Much more reasonable.
+setw -g aggressive-resize on
+
+# Allows us to use C-a a <command> to send commands to a TMUX session inside
+# another TMUX session
+bind-key a send-prefix
+
+# Highlight active window
+set-window-option -g window-status-current-bg red
+
+# Examples
+# --------
+
+# Activity monitoring
+#setw -g monitor-activity on
+#set -g visual-activity on
+
+# Example of using a shell command in the status line
+#set -g status-right "#[fg=yellow]#(uptime | cut -d ',' -f 2-)"
+
57 tmx
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+#
+# Tmux launcher
+#
+# See:
+# http://github.com/brandur/tmux-extra
+#
+# Modified version of a script orginally found at:
+# http://forums.gentoo.org/viewtopic-t-836006-start-0.html
+#
+
+# Works because bash automatically trims by assigning to variables and by
+# passing arguments
+trim() { echo $1; }
+
+if [[ -z "$1" ]]; then
+ echo "Specify session name as the first argument"
+ exit
+fi
+
+# Only because I often issue `ls` to this script by accident
+if [[ "$1" == "ls" ]]; then
+ tmux ls
+ exit
+fi
+
+base_session="$1"
+# This actually works without the trim() on all systems except OSX
+tmux_nb=$(trim `tmux ls | grep -P "^$base_session" | wc -l`)
+if [[ "$tmux_nb" == "0" ]]; then
+ echo "Launching tmux base session $base_session ..."
+ tmux new -s $base_session
+else
+ # Make sure we are not already in a tmux session
+ if [[ -z "$TMUX" ]]; then
+ # Kill defunct sessions first
+ old_sessions=$(tmux ls | egrep "^[0-9]{14}.*[0-9]+\)$" | cut -f 1 -d:)
+ for old_session_id in $old_sessions; do
+ tmux kill-session -t $old_session_id
+ done
+
+ echo "Launching copy of base session $base_session ..."
+ # Session is is date and time to prevent conflict
+ session_id=`date +%Y%m%d%H%M%S`
+ # Create a new session (without attaching it) and link to base session
+ # to share windows
+ tmux new-session -d -t $base_session -s $session_id
+ # Create a new window in that session
+ #tmux new-window
+ # Attach to the new session
+ tmux attach-session -t $session_id
+ # When we detach from it, kill the session
+ tmux kill-session -t $session_id
+ fi
+fi
+

0 comments on commit 6b28b10

Please sign in to comment.
Something went wrong with that request. Please try again.