Created
July 28, 2016 10:43
-
-
Save bserem/3f39fe0f092f291fa98b0518c80b923a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set Ctrl-a as control instead of ctrl-b | |
unbind C-b | |
set -g prefix C-a | |
bind C-a send-prefix | |
# Nested Multiplexers | |
bind-key a send-prefix | |
# Switch to last window with two C-a | |
bind-key C-a last-window | |
# Start numbering at 1 | |
set -g base-index 1 | |
# Highlight active window | |
set-window-option -g window-status-current-bg white | |
set-window-option -g window-status-current-fg red | |
# Faster commands | |
#set -s escape-time 0 | |
# Resize to smallest client, but per window and not per session | |
setw -g aggressive-resize on | |
#set -g default-terminal "screen-256color" | |
# Big scrollback | |
set -g history-limit 10000 | |
# Red status line, because you are on the live server! | |
set status-utf8 on | |
set -g utf8 on | |
set -g default-terminal "screen-256color" | |
set -g status-bg red | |
set -g status-fg white | |
# Load in status line | |
set -g status-right "#[fg=black]#(uptime | cut -d ',' -f 4-)" | |
# Select window with mouse click | |
#set -g mode-mouse on | |
#set -g mouse-select-window on | |
#set -g mouse-select-pane on | |
# Activity monitoring | |
#setw -g monitor-activity on | |
#set -g visual-activity on | |
# Ctrl+Arrows skip words | |
set-window-option -g xterm-keys on | |
# VI keybindings | |
set -g status-keys vi | |
setw -g mode-keys vi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Modified TMUX start script from: | |
# http://forums.gentoo.org/viewtopic-t-836006-start-0.html | |
# | |
# Store it to `~/bin/tmx` and issue `chmod +x`. | |
# | |
# 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 "^$base_session" | wc -l`) | |
if [[ "$tmux_nb" == "0" ]]; then | |
echo "Launching tmux base session $base_session ..." | |
tmux new-session -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 2>/dev/null | 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment