Skip to content

Instantly share code, notes, and snippets.

@gardiner
Created October 17, 2012 20:26
Show Gist options
  • Save gardiner/3907932 to your computer and use it in GitHub Desktop.
Save gardiner/3907932 to your computer and use it in GitHub Desktop.
function freeze() {
LAYOUT=`tmux list-windows -F "#{window_active} #{window_layout}" | grep "^1" | cut -d " " -f 2`
CWD=`pwd`
echo "windows:"
echo " - name: \"${NAME:-NAME}\""
echo " layout: \"${LAYOUT}\""
echo " root: \"${CWD}\""
echo " filters:"
echo " before: \"pwd\""
echo " splits:"
for P in `tmux list-panes -F "#{pane_pid}"` ; do
COMMAND=`ps -a -x -o ppid,command | grep "^ *${P}" | grep -Ev "grep|-bash" | tail -n 1 | sed -e "s/ *${P} *//;"`
echo " - cmd: \"${COMMAND:-pwd}\""
done
}
if [[ ${1:-} == "-i" ]] ; then
PROPOSAL=`basename $(pwd)`
echo -n "Project Name [${PROPOSAL}]: "
read NAME
NAME=${NAME:-${PROPOSAL}}
TARGET=~/.teamocil/${NAME}.yml
if ls ${TARGET} > /dev/null 2>&1 ; then
echo "Project already exists"
else
echo "Writing layout to ${TARGET}"
freeze >> ${TARGET}
fi
echo "Adjust using \"teamocil --edit ${NAME}\""
else
freeze
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment