-
-
Save jdevera/4b910d5a7dac4e6fca7d9f6bb8c4536d to your computer and use it in GitHub Desktop.
Revisions
-
Michelle Gill revised this gist
Nov 15, 2014 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,11 +17,13 @@ # You will also need to edit the execution command ($exec_cmd) # below which is what is run in each tmux pane. By default, it is: # "time $process $ct $nthread" # time : the unix time command # $process : name of the process to execute # $ct : the 0-indexed pane number, which I use as an # argument in the $process script for parallelization # $nthread : the total number of threads, also used for as an # argument in $process for parallelization # Michelle L. Gill, 2014-11-15 @@ -106,7 +108,7 @@ fi if [[ $process != "" ]]; then ct=0 while [[ $ct -lt $nthread ]]; do exec_cmd="time $process $ct $nthread" tmux send-keys -t $sess_name.$ct "$exec_cmd" Enter (( ct++ )) done -
Michelle Gill revised this gist
Nov 15, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ # Usage: # tmuxp process [number of threads] [session name] # process : name of the shell script or process to execute # can be set to "" to only open tmux panes # threads : number of threads to execute [optional] # session name : name of tmux session [optional] -
Michelle Gill revised this gist
Nov 15, 2014 . 1 changed file with 11 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ # Usage: # tmuxp process [number of threads] [session name] # process : name of the shell script or process to execute # : can be set to "" to only open tmux panes # threads : number of threads to execute [optional] # session name : name of tmux session [optional] @@ -102,12 +103,15 @@ if [[ $nthread -gt 2 ]]; then fi # Start the processes if [[ $process != "" ]]; then ct=0 while [[ $ct -lt $nthread ]]; do exec_cmd="time $process $ct" tmux send-keys -t $sess_name.$ct "$exec_cmd" Enter (( ct++ )) done fi tmux select-pane -t $sess_name.0 tmux -2 attach-session -t $sess_name -
Michelle Gill revised this gist
Nov 15, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ else exit 0 fi # Set the number of threads, which corresponds to the number of panes if [[ $argc -ge 2 ]]; then nthread=$2 else @@ -50,7 +50,7 @@ fi if [[ $argc -ge 3 ]]; then sess_name=$3 else sess_name=tmuxifier fi # Test if the session exists -
Michelle Gill revised this gist
Nov 15, 2014 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ #!/bin/bash # The "tmuxifier" # Execute parallel processes in an arbitrary number of tmux panes # This script requires the path to an existing script to # execute in parallel. Optionally, the number of threads to # and the name of the tmux session can be input. If threads -
Michelle Gill created this gist
Nov 15, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,112 @@ #!/bin/bash # The "tmuxifier": execute parallel processes in tmux panes # This script requires the path to an existing script to # execute in parallel. Optionally, the number of threads to # and the name of the tmux session can be input. If threads # and session name are not entered, threads are determined # automatically and session names is set to a default. # Usage: # tmuxp process [number of threads] [session name] # process : name of the shell script or process to execute # threads : number of threads to execute [optional] # session name : name of tmux session [optional] # You will also need to edit the execution command ($exec_cmd) # below which is what is run in each tmux pane. By default, it is: # "time $process $ct" # time : the unix time command # $process : name of the process to execute # $ct : the 0-indexed pane number, which I use as an # argument in the $process script for parallelization # Michelle L. Gill, 2014-11-15 argc=$# # Set the process name if [[ $argc -ge 1 ]]; then process=$1 else echo "Usage: $0 process [number of threads] [session name]" exit 0 fi # Set the number of threads, which corresponds to the number of windows if [[ $argc -ge 2 ]]; then nthread=$2 else # Determine automatically on Mac or Linux if [[ `uname` == 'Darwin' ]]; then nthread=`sysctl hw.ncpu | awk '{print $2}'` else nthread=`nproc` fi fi # Set the session name if [[ $argc -ge 3 ]]; then sess_name=$3 else sess_name=test fi # Test if the session exists tmux has-session -t $sess_name 2> /dev/null exit=$? if [[ $exit -eq 0 ]]; then echo "Session $sess_name exists. Kill it? [y/N]" read kill_sess if [[ ($kill_sess == "y") || ($kill_sess == "Y") ]]; then tmux kill-session -t $sess_name else echo "Session not created because it already exists. Exiting." exit 0 fi fi # Create the session tmux new-session -d -s $sess_name # Set the number of rows nrow=0 if [[ $nthread -eq 2 ]]; then nrow=2 elif [[ $nthread -gt 2 ]]; then # Ceiling function to round up if odd nrow=`echo "($nthread+1)/2" | bc` fi # Create the rows ct=$nrow while [[ $ct -gt 1 ]]; do frac=`echo "scale=2;1/$ct" | bc` percent=`echo "($frac * 100)/1" | bc` tmux select-pane -t $sess_name.0 tmux split-window -v -p $percent (( ct-- )) done # Create the columns if [[ $nthread -gt 2 ]]; then # Floor function to round down if odd ct=`echo "$nthread/2-1" | bc` while [[ $ct -ge 0 ]]; do tmux select-pane -t $sess_name.$ct tmux split-window -h -p 50 (( ct-- )) done fi # Start the processes ct=0 while [[ $ct -lt $nthread ]]; do exec_cmd="time $process $ct" tmux send-keys -t $sess_name.$ct "$exec_cmd" Enter (( ct++ )) done tmux -2 attach-session -t $sess_name