-
-
Save qleguennec/c13e4db09358ee415ecc to your computer and use it in GitHub Desktop.
This file contains hidden or 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/sh | |
function layout() | |
{ | |
tmux lsw | head -n 1 | egrep -o -e "\[layout.*$" | awk '{print $2}' | sed 's/.$//' | |
} | |
function curwindow() | |
{ | |
tmux lsw | awk '{print $2}' | grep '*' | sed 's/.$//' | |
} | |
function cursession() | |
{ | |
tmux ls | grep attached | cut -d: -f1 | |
} | |
function conf() | |
{ | |
echo "$HOME/.tmuxinator/$(cursession).yml" | |
} | |
case $1 in | |
only) | |
if [[ -n "$2" ]]; then | |
tmux switch-client -t "$2" | |
tmux ls | cut -d: -f1 | grep -v "$2" | xargs -I{} tmux kill-session -t {} | |
else | |
tmux ls | grep -v attached | cut -d: -f1 | xargs -I{} tmux kill-session -t {} | |
fi | |
;; | |
reload) | |
OLD=$(tmux ls | grep attached | cut -d: -f1) | |
tmux new-session -d -s buffer "mux start $OLD" | |
tmux switch-client -t buffer | |
tmux kill-session -t "$OLD" | |
;; | |
layout) | |
layout | |
;; | |
save-layout) | |
LINE=$(grep -n -A1 "$(curwindow)" "$(conf)" | tail -n 1 | cut -d- -f1) | |
sed -i $LINE's/layout:.*/layout: '$(layout)'/' $(conf) | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment