Created
August 22, 2015 23:31
-
-
Save cmizony/324b0143d0a832f9427f to your computer and use it in GitHub Desktop.
Example of automated multiplexer session
This file contains 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 | |
# | |
# ____ __ __ ___ ________ _ ___ __ ____ | |
# / ___| \/ |_ _|__ / _ \| \ | \ \ / / / ___| ___ _ __ ___ ___ _ __ | |
# | | | |\/| || | / / | | | \| |\ V / _____ \___ \ / __| '__/ _ \/ _ \ '_ \ | |
# | |___| | | || | / /| |_| | |\ | | | |_____| ___) | (__| | | __/ __/ | | | | |
# \____|_| |_|___/____\___/|_| \_| |_| |____/ \___|_| \___|\___|_| |_| | |
# | |
# | |
# Create simple screen layout (bottom split) | |
# Any session can be loaded in it. Use `:fit` to adapt content size | |
# | |
source screenUtils.sh | |
# Main Window | |
xdotool key "ctrl+A" "S" # split horizontal | |
xdotool key "ctrl+a" "Tab" | |
# Bottom Window | |
screenResizeWindow 10 # size height | |
xdotool key "ctrl+a" "bar" # split vertical | |
xdotool key "ctrl+a" "bar" # split vertical | |
# Bottom Left Window | |
screenResizeWindow -10 # size width | |
#Bottom Middle Window | |
xdotool key "ctrl+a" "Tab" | |
screenResizeWindow 100 # size width | |
# Back main Window | |
xdotool key "ctrl+a" "Tab" | |
xdotool key "ctrl+a" "Tab" |
This file contains 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 | |
# | |
# ____ __ __ ___ ________ _ ___ __ ____ | |
# / ___| \/ |_ _|__ / _ \| \ | \ \ / / / ___| ___ _ __ ___ ___ _ __ | |
# | | | |\/| || | / / | | | \| |\ V / _____ \___ \ / __| '__/ _ \/ _ \ '_ \ | |
# | |___| | | || | / /| |_| | |\ | | | |_____| ___) | (__| | | __/ __/ | | | | |
# \____|_| |_|___/____\___/|_| \_| |_| |____/ \___|_| \___|\___|_| |_| | |
# | |
# | |
# Example of full initialization for `screen` session | |
# | |
source screenUtils.sh | |
################## | |
# Create windows # | |
################## | |
# Main windows | |
screenRenameWindow "0" | |
xdotool type "cd ~/Documents/github/climbing-memo" | |
xdotool key "KP_Enter" | |
xdotool type "vi" | |
xdotool key "KP_Enter" | |
# Simple windows | |
screenCreateWindow "1" "htop" | |
# Bootstrap project | |
screenCreateWindow "3" | |
xdotool type "cd ~/Documents/github/climbing-memo && grunt serve" | |
xdotool key "KP_Enter" | |
screenCreateWindow "2" "cd ~ && td && td --done" | |
################# | |
# Create layout # | |
################# | |
# Top Right window | |
xdotool key "ctrl+a" "bar" # split vertical | |
xdotool key "ctrl+a" "Tab" | |
screenSwitchWindow "2" | |
screenResizeWindow 45 # size width | |
xdotool key "ctrl+A" "S" # split horizontal | |
xdotool key "ctrl+A" "S" # split horizontal | |
screenResizeWindow 7 # size height | |
# Middle Right window | |
xdotool key "ctrl+a" "Tab" | |
screenSwitchWindow "2" | |
# Bottom right window | |
xdotool key "ctrl+a" "Tab" | |
screenSwitchWindow "3" | |
# Back to Main window | |
xdotool key "ctrl+a" "Tab" | |
screenSwitchWindow "0" |
This file contains 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 | |
# | |
# ____ __ __ ___ ________ _ ___ __ ____ | |
# / ___| \/ |_ _|__ / _ \| \ | \ \ / / / ___| ___ _ __ ___ ___ _ __ | |
# | | | |\/| || | / / | | | \| |\ V / _____ \___ \ / __| '__/ _ \/ _ \ '_ \ | |
# | |___| | | || | / /| |_| | |\ | | | |_____| ___) | (__| | | __/ __/ | | | | |
# \____|_| |_|___/____\___/|_| \_| |_| |____/ \___|_| \___|\___|_| |_| | |
# | |
# | |
# Create shared `screem` session with default name "shared" | |
# | |
sessionName="shared" | |
if [ $# -eq 1 ] | |
then | |
sessionName=$1 | |
fi | |
screen -dmS $sessionName | |
screen -x $sessionName |
This file contains 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 | |
# | |
# ____ __ __ ___ ________ _ ___ __ ____ | |
# / ___| \/ |_ _|__ / _ \| \ | \ \ / / / ___| ___ _ __ ___ ___ _ __ | |
# | | | |\/| || | / / | | | \| |\ V / _____ \___ \ / __| '__/ _ \/ _ \ '_ \ | |
# | |___| | | || | / /| |_| | |\ | | | |_____| ___) | (__| | | __/ __/ | | | | |
# \____|_| |_|___/____\___/|_| \_| |_| |____/ \___|_| \___|\___|_| |_| | |
# | |
# | |
# Set of utils function to programmatically manipulate `screen` | |
# | |
# apt-get install xdotool | |
# List of keys http://wiki.linuxquestions.org/wiki/List_of_Keysyms_Recognised_by_Xmodmap | |
# Bash parameters http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion | |
# Desc Press a key N times | |
# param $1 Key to press | |
# param $2 number of timer (optional) | |
screenRepeatKeyPress () { | |
defaultTimes=1 | |
repeatTimes=${2:-$defaultTimes} | |
for i in `seq $repeatTimes`; do | |
xdotool key $1 | |
done | |
} | |
# Desc Rename current window | |
# param $1 New name | |
screenRenameWindow () { | |
xdotool key "ctrl+A" "A" # rename | |
screenRepeatKeyPress "BackSpace" 20 | |
xdotool type $1 | |
xdotool key "KP_Enter" | |
} | |
# Desc Create named window | |
# param $1 window name | |
# param $2 command to run (optional) | |
screenCreateWindow () { | |
xdotool key "ctrl+A" "c" # new window | |
screenRenameWindow $1 | |
if [ ! -z "$2" ]; then | |
xdotool type "$2" | |
xdotool key "KP_Enter" | |
fi | |
} | |
# Desc Switch to exising window | |
# param $1 name window | |
screenSwitchWindow () { | |
xdotool key "ctrl+a" "apostrophe" | |
xdotool type "$1" | |
xdotool key "KP_Enter" | |
} | |
# Desc Resize current window | |
# param $1 size | |
screenResizeWindow () { | |
xdotool key "ctrl+a" "colon" | |
xdotool type "resize $1" | |
xdotool key "KP_Enter" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment