Last active
December 12, 2015 06:19
-
-
Save jssjr/4728357 to your computer and use it in GitHub Desktop.
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
# arg1 = "String to expand as the run command, $key will be interpretted as the item name" | |
# arg2..n = items to iterate across | |
function tmux_windows() { | |
session="tmux-cmd-$$" | |
tmux new-session -d -s $session | |
cmd=$1 ; shift | |
index=1 | |
while [ ! -z $1 ] ; do | |
index=$((++index)) | |
export var=$1 ; shift | |
run=$(eval echo $cmd) | |
tmux new-window -t ${session}:${index} -n "${var}" "${run}" | |
done | |
tmux select-window -t ${session}:1 | |
tmux -2 attach-session -t ${session} | |
} | |
#tmux_windows '/bin/sh' "a" "b" | |
tmux_windows 'tail -f $var' "/var/log/system.log" "/var/log/secure.log" |
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
#!/usr/bin/env bash | |
# arg1 = "String to expand as the run command, $key will be interpretted as the item name" | |
# arg2..n = items to iterate across | |
function tmux_windows() { | |
session="tmux-cmd-$$" | |
tmux new-session -d -s $session | |
cmd=$1 ; shift | |
index=1 | |
while [ ! -z $1 ] ; do | |
index=$((++index)) | |
export var=$1 ; shift | |
run=$(eval echo $cmd) | |
tmux new-window -t ${session}:${index} -n "${var}" | |
tmux send-keys "$run" 'C-m' | |
done | |
tmux select-window -t ${session}:1 | |
tmux -2 attach-session -t ${session} | |
} | |
#tmux_windows '/bin/sh' "a" "b" | |
tmux_windows 'tail -f $var' "/var/log/system.log" "/var/log/secure.log" |
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
#!/usr/bin/env bash | |
# arg1 = "String to expand as the run command, $key will be interpretted as the item name" | |
# arg2..n = items to iterate across | |
function tmux_windows() { | |
session="tmux-cmd-$$" | |
tmux new-session -d -s $session | |
cmd=$1 ; shift | |
index=1 | |
while [ ! -z $1 ] ; do | |
index=$((++index)) | |
export var=$1 ; shift | |
run=$(echo "$cmd" | sed -e "s%\$var%$var%g") | |
tmux new-window -t ${session}:${index} -n "${var}" | |
tmux send-keys "$run" 'C-m' | |
done | |
tmux select-window -t ${session}:1 | |
tmux -2 attach-session -t ${session} | |
} | |
#tmux_windows '/bin/sh' "a" "b" | |
#tmux_windows 'echo "$var" && tail -f $var' "/var/log/system.log" "/var/log/secure.log" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment