Skip to content

Instantly share code, notes, and snippets.

@foca
Created February 7, 2015 21:16
Show Gist options
  • Save foca/1d396698c2f9fc71b0e4 to your computer and use it in GitHub Desktop.
Save foca/1d396698c2f9fc71b0e4 to your computer and use it in GitHub Desktop.
A tool to load a `.tmuxify.layout` file and open a GNU Screen session with it. See https://github.com/tonchis/tmuxify
#!/usr/bin/env bash
set -e
[ -n "$DEBUG" ] && set -x
layout="$(pwd)/.tmuxify.layout"
if [ ! -f "$layout" ]; then
echo "Can't find ./.tmuxify.layout" >&2
exit 1
fi
session="${1:-$(basename $(pwd))}"
screen -S "$session" -d -m
cat "$layout" | while read window pane command; do
screen -S "$session" -X screen -t "$window" "pane";
screen -S "$session" -X select "pane";
screen -S "$session" -X stuff "$command\n";
done
screen -rd "$session";
@foca
Copy link
Author

foca commented Feb 7, 2015

The way to select the session that will be active at the end is to make it the last one in the .tmuxify.layout file. So for example, with this file:

shell   3    gs in
irb     2    gs in && irb -r ./init
server  1    gs in && shotgun
vim     0    gs in && vim .

Vim (window 0) will be the one selected when the user runs screenify.

@pote
Copy link

pote commented Feb 7, 2015

Pretty! You should make this easily installable!

Or maybe I can just curl the file into my PATH because I have run out of fucks to give.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment