#!/usr/bin/env sh # Session Name from filename (e.g _tmux_workspace_name,-- description --> name) SESSION="$(echo "${0##*/}" | cut -d ',' -f1 | cut -d '_' -f4)" SESSIONEXISTS=$(tmux list-sessions | grep "$SESSION") # Only create tmux session if it doesn't already exist if [ "$SESSIONEXISTS" = "" ]; then # create new session tmux new-session -d -s "$SESSION" -c "$HOME" tmux rename-window -t "$SESSION":0 'fm' tmux send-keys -t "$SESSION":0 'ranger ~/Downloads' C-m tmux new-window -t "$SESSION":1 -n 'spool' -c "$HOME" tmux send-keys -t "$SESSION":1 'watch tsp' C-m tmux split-window -t "$SESSION":1 -v -c "$HOME" tmux send-keys -t "$SESSION":1 'watch TS_SOCKET=/tmp/fm tsp' C-m tmux split-window -t "$SESSION":1 -v -p 10 -c "$HOME" tmux new-window -t "$SESSION":2 -n 'cmd' -c "$HOME" # jump to session and window 0 tmux switch-client -t "$SESSION":0 else # if exist then jump to session tmux switch-client -t "$SESSION" fi