Created
August 10, 2015 19:57
-
-
Save jasonbot/ae16237b721e60eec6a0 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/bash | |
| SESSION_NAME=$( tmux display-message -p '#S' 2> /dev/null ) | |
| WINDOW_TITLE="Workspace" | |
| check_session() | |
| { | |
| if [ x$SESSION_NAME == "x" ] | |
| then | |
| echo "Please do this in a tmux session" | |
| exit 1 | |
| fi | |
| } | |
| close_window() | |
| { | |
| tmux kill-window -t $WINDOW_TITLE 2> /dev/null | |
| } | |
| open_window() | |
| { | |
| tmux new-window -n $WINDOW_TITLE htop | |
| tmux select-window $WINDOW_TITLE | |
| tmux split-window "tail -f $0" | |
| tmux split-window | |
| tmux select-layout even-vertical | |
| } | |
| start_session() | |
| { | |
| check_session | |
| stop_session | |
| open_window | |
| } | |
| stop_session() | |
| { | |
| check_session | |
| close_window | |
| } | |
| case x$1 in | |
| xstart) | |
| start_session | |
| ;; | |
| xstop) | |
| stop_session | |
| ;; | |
| x) | |
| echo "Usage: $0 [start|stop]" | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment