feat(tmuxinator): add a command for auto creation of tmux sessions
This commit is contained in:
@@ -403,3 +403,6 @@ function gpla() {
|
|||||||
|
|
||||||
echo "Finished fetching branches."
|
echo "Finished fetching branches."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# source the tmux-sessions.sh in the same folder
|
||||||
|
source $(dirname "$0")/tmux-sessions.sh
|
||||||
|
|||||||
28
omz-custom/tmux-sessions.sh
Normal file
28
omz-custom/tmux-sessions.sh
Normal 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
|
||||||
10
tmuxinator/template.yml.temp
Normal file
10
tmuxinator/template.yml.temp
Normal 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
|
||||||
Reference in New Issue
Block a user