Create .tmux files

If `experimental.createTmuxStartupFile` is set in `build.yaml`.
This commit is contained in:
Oliver Davies 2024-01-26 14:58:41 +00:00
parent 8818baed58
commit 09da2bc403
4 changed files with 42 additions and 0 deletions

View file

@ -146,6 +146,13 @@ final class CreateListOfFilesToGenerate
break; break;
} }
if (Arr::get($configurationData, 'experimental.createTmuxStartupFile') === true) {
$filesToGenerate[] = new TemplateFile(
data: 'common/.tmux',
name: '.tmux',
);
}
$filesToGenerate[] = new TemplateFile( $filesToGenerate[] = new TemplateFile(
data: 'common/.githooks/prepare-commit-msg', data: 'common/.githooks/prepare-commit-msg',
name: 'prepare-commit-msg', name: 'prepare-commit-msg',

View file

@ -59,6 +59,10 @@ final class GenerateConfigurationFiles
$this->filesystem->chmod("{$this->outputDir}/.githooks/prepare-commit-msg", 0755); $this->filesystem->chmod("{$this->outputDir}/.githooks/prepare-commit-msg", 0755);
} }
if ($this->filesystem->exists("{$this->outputDir}/.tmux")) {
$this->filesystem->chmod("{$this->outputDir}/.tmux", 0755);
}
if ($this->filesystem->exists("{$this->outputDir}/run")) { if ($this->filesystem->exists("{$this->outputDir}/run")) {
$this->filesystem->chmod("{$this->outputDir}/run", 0755); $this->filesystem->chmod("{$this->outputDir}/run", 0755);
} }

View file

@ -116,6 +116,10 @@ final class ConfigDto
new Assert\Type('bool'), new Assert\Type('bool'),
]), ]),
'createTmuxStartupFile' => new Assert\Optional([
new Assert\Type('bool'),
]),
'runGitHooksBeforePush' => new Assert\Optional([ 'runGitHooksBeforePush' => new Assert\Optional([
new Assert\Type('bool'), new Assert\Type('bool'),
]), ]),

27
templates/common/.tmux.twig Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
session_name="${1:-{{ name }}}"
session_path="${2:-$(pwd)}"
if tmux has-session -t="${session_name}" 2> /dev/null; then
tmux attach -t "${session_name}" ||
tmux switch-client -t "${session_name}"
fi
tmux new-session -d -s "${session_name}" -n vim -c "${session_path}"
# 1. Main window: Vim.
tmux send-keys -t "${session_name}:vim" "nvim" Enter
tmux split-pane -t "${session_name}:vim" -h -c "${session_path}" -p 40
tmux send-keys -t "${session_name}:vim.right" "./run start" Enter
# 2. General shell use.
tmux new-window -t "${session_name}" -c "${session_path}"
tmux switch-client -t "${session_name}:vim.left" ||
tmux attach -t "${session_name}:vim.left"
# vim: ft=bash