tmuxify
Updated at 2020-02-26 12:36
Most projects I work on require running multiple processes in parallel for development; e.g. webserver, CSS pre-processor, some microservices, TypeScript compiler.
On Mac, I used to use iTerm tab macros for that but nowadays prefer tmux
as it's more powerful and multi-platform .
Example: add the following to your .bashrc
and then you can call rukruk
in shell.
rukruk() {
local NAME="rukruk"
tmux has-session -t=":$NAME" 2>/dev/null
if [ $? == 0 ]; then
echo "$NAME window already exists, aborting"
return 0
fi
# if we aren't in a tmux session, create a new session
# if we are in a tmux session, create a new window
if [ -z "$TMUX" ]; then
tmux start-server
tmux new-session -d -s $NAME -n $NAME
else
tmux new-window -n $NAME
fi
tmux send-keys "v ruksismith" C-m
tmux send-keys "bash unix_host.sh" C-m
tmux split-window -v
tmux send-keys "v ruksismith" C-m
tmux send-keys "bash unix_build.sh" C-m
# if we aren't in a tmux session, open the session
if [ -z "$TMUX" ]; then
tmux attach-session -t $NAME
fi
}