feat(tmuxinator): add a command for auto creation of tmux sessions

This commit is contained in:
2025-10-04 11:22:22 +02:00
parent 8917aab783
commit ac37ea1b0b
3 changed files with 41 additions and 0 deletions

View File

@@ -403,3 +403,6 @@ function gpla() {
echo "Finished fetching branches."
}
# source the tmux-sessions.sh in the same folder
source $(dirname "$0")/tmux-sessions.sh

View File

@@ -0,0 +1,28 @@
function mux() {
project_dir=$1
if [[ -z "$project_dir" ]]; then
echo "Usage: mux <project_directory> [session_name]"
return 1
fi
session_name=${2:-$(basename $(realpath "$project_dir"))}
whole_path=$(realpath "$project_dir")
if [[ $whole_path == "*No such file or directory*" ]]; then
echo "Directory does not exist: $project_dir"
return 1
fi
# check if file doesn't exist yet in the tmuxinator config directory
tmuxinator_config=~/.config/tmuxinator/$session_name.yml
if [[ -f $tmuxinator_config ]]; then
echo "File already exists"
else
cp ~/.config/tmuxinator/template.yml.temp $tmuxinator_config
# replace variables in placeholder config with real values - PROJECT_NAME, PROJECT_ROOT
sed -i '' "s|{{\$PROJECT_NAME}}|$session_name|g" $tmuxinator_config
sed -i '' "s|{{\$PROJECT_ROOT}}|$whole_path|g" "$tmuxinator_config"
fi
tmuxinator start $session_name
}
complete -o default mux

View File

@@ -0,0 +1,10 @@
---
name: {{$PROJECT_NAME}}
project_root: {{$PROJECT_ROOT}}
windows:
- zsh:
layout: b8f6,198x59,0,0[198x39,0,0,71,198x19,0,40{99x19,0,40,73,98x19,100,40,75}]
panes:
- nvim
-
- dcud