Skip to content

Instantly share code, notes, and snippets.

@dlains dlains/qs
Created Jan 15, 2019

Embed
What would you like to do?
Quick tmux session script
#!/usr/bin/env bash
# Create a quick tmux session with an editor window and
# a console window. The session will be named after the
# directory supplied as an argument.
#
# Usage:
# qs path
#
# Check the arguments. There should be one argument only.
if [[ $# < 1 ]]; then
printf "%b" "Error, not enough arguments.\n" >&2
printf "%b" "Usage: qs path\n" >&2
exit 1
elif [[ $# > 1 ]]; then
printf "%b" "Error, too many arguments.\n" >&2
printf "%b" "Usage: qs path\n" >&2
exit 2
fi
# Verify that the argument is a directory.
if [[ ! -d $1 ]]; then
printf "%b" "Error, the given argument is not a directory.\n" >&2
printf "%b" "Usage: qs path\n" >&2
exit 3
fi
NAME=`basename $1`
cd $1
tmux new -s $NAME -n editor -d
tmux send-keys -t $NAME $EDITOR C-m
tmux new-window -n console -t $NAME
tmux select-window -t $NAME:1
tmux attach -t $NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.