#!/bin/bash tmux_conf() { tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf "$@" } type="${1:-bash}" if [ -n "$TMUX" ]; then m=switch-client else m=attach-session fi case "$type" in "bash") start_dir="$HOME";; "remote") start_dir="$HOME";; "puppet") start_dir="/etc/puppetlabs/code" esac if tmux has-session -t "$type" 2>/dev/null; then tmux $m -t "$type" else if [ "$type" = "remote" ]; then tmux_conf new-session -d -c $start_dir -s "$type" mosh immae.eu \; \ $m -t "$type" elif [ -n "$start_dir" ]; then tmux_conf new-session -d -c $start_dir -s "$type" \; \ $m -t "$type" \; \ new-window -c $start_dir elif [ -d "$HOME/workdir/$type" ]; then tmux_conf new-session -d -c "$HOME/workdir/$type" -s "$type" \; \ $m -t "$type" \; \ send-keys "../start" C-m \; \ rename-window "running" \; \ new-window -c "$HOME/workdir/$type" else echo "Unknown session" >&2 exit 1 fi fi