From 0b65c73c34fa11c76c09c0a345ac686157f168b9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 14 Jul 2023 15:29:39 +0200 Subject: [PATCH] added tmux startup script --- start.bash | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 start.bash diff --git a/start.bash b/start.bash new file mode 100755 index 0000000..590f058 --- /dev/null +++ b/start.bash @@ -0,0 +1,58 @@ +#!/bin/bash + +DCAITI_PATH=. + +# Define your windows, working dirs, and commands +declare -a windows=( + "performance" + "base" + "remote_control" + "lidar" + "nav2" +) +declare -a work_dirs=( + $HOME + $DCAITI_PATH + $DCAITI_PATH/src/dcaitirobot/launch + $DCAITI_PATH + $DCAITI_PATH/src/dcaitirobot/launch + #$DCAITI_PATH/src/dcaiti_navigation/launch +) +declare -a commands=( + "htop" + "ros2 launch dcaiti_control launch_robot.py" + "ros2 launch remote_control_launch.py" + "ros2 launch velodyne velodyne-all-nodes-VLP16-launch.py" + "ros2 launch launch_slam.py" + #"ros2 launch start_nav2.py" +) + +# Start tmux +tmux start-server + +SESSION=dcaiti + +# Create a new session without attaching yet +tmux new-session -d -s $SESSION + +# Iterate over sessions array and create them +for index in ${!windows[*]}; do + window=${windows[$index]} + work_dir=${work_dirs[$index]} + command=${commands[$index]} + + # If it's the first window, rename the existing window, otherwise create a new one + if [ $index -eq 0 ]; then + tmux rename-window -t $SESSION:0 $window + else + tmux new-window -t $SESSION -n $window + fi + + # Switch to work_dir and execute the command + tmux send-keys -t $SESSION:$window "cd $work_dir" C-m + tmux send-keys -t $SESSION:$window "$command" C-m +done + +# Finally attach to the tmux session +tmux attach-session -t $SESSION +