Skip to content

Instantly share code, notes, and snippets.

@jssjr
Last active December 12, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jssjr/4728357 to your computer and use it in GitHub Desktop.
Save jssjr/4728357 to your computer and use it in GitHub Desktop.
# 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"
#!/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"
#!/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