From 04d2d424af6cf0f94067b9eb07435c2ef0134730 Mon Sep 17 00:00:00 2001 From: cyteen Date: Wed, 11 Mar 2026 01:45:38 +0000 Subject: [PATCH] Split from the tmux install script and extra examples. --- 020_tmux-tmuxp.sh | 129 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 020_tmux-tmuxp.sh diff --git a/020_tmux-tmuxp.sh b/020_tmux-tmuxp.sh new file mode 100644 index 0000000..099e5b0 --- /dev/null +++ b/020_tmux-tmuxp.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +# Optional: tmuxp + completions + example sessions + +# 1. Install tmuxp (if not already done via pip/poetry/whatever) +# pip install --user tmuxp # or use your preferred method + +# 2. Install shtab for shell completions (highly recommended) +sudo apt update && sudo apt install -y tmuxp python3-shtab # or pip install shtab + +# 3. Generate completions +# Adjust paths if your distro uses different locations + +# Zsh +ZSH_COMP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions" +# ZSH_COMP_DIR="/usr/share/zsh/vendor-completions" +mkdir -p "$ZSH_COMP_DIR" +shtab --shell=zsh tmuxp.cli.create_parser | sudo tee "$ZSH_COMP_DIR/_tmuxp" >/dev/null + +# Bash +BASH_COMP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions" +# BASH_COMP_DIR="/usr/share/bash-completion/completions" +mkdir -p "$BASH_COMP_DIR" +shtab --shell=bash tmuxp.cli.create_parser | sudo tee "$BASH_COMP_DIR/tmuxp" >/dev/null + +echo "Completions installed. You may need to restart your shell or run:" +echo " source ~/.zshrc # or source ~/.bashrc" + +# 4. Optional: create example tmuxp configs in ~/.config/tmuxp/ +mkdir -p ~/.config/tmuxp + +conf_print_tmuxp_yaml() { + cat <<'EOF' +session_name: yazi-plugin-dev +start_directory: ./ + +before_script: tmux run-shell -b 'mise run watch' + +windows: + - window_name: debug-env + layout: main-vertical + options: + main-pane-width: 60% + panes: + - shell_command: + - nvim ${FILE_TO_EDIT:-.} + focus: true + - shell_command: + - yazi + - shell_command: + - "> ~/.local/state/yazi/yazi.log && tail -F ~/.local/state/yazi/yazi.log" +EOF +} +conf_print_tmuxp_yaml | tee ~/.config/tmuxp/yazi-plugin-dev.yaml +conf_print_tmuxp_yaml | tee "${PLUGIN_DIR}/.tmuxp.yaml" + +# Dince we run mise we can set variables in the plugin dir +# .mise,toml rather than a tmuxp yml file.we can then call +# it with `mise run dev` +conf_print_mise_toml() { + cat <yr", function() + vim.fn.system("yazi --remote reload") + print("Yazi reloaded!") +end, { desc = "Yazi: Remote Reload" }) +EOF +} +# conf_print_nvim_yazi-reload | tee ~/.config/nvim/after/plugin/yazi-reload.lua + +cat >~/.config/tmuxp/docker.yaml <<'EOF' +session_name: docker +start_directory: ./ +windows: +- window_name: dockerfiles + layout: tiled + panes: + - vim Dockerfile + - bash + - bash +- window_name: compose + panes: + - docker compose up +EOF + +cat >~/.config/tmuxp/dev.yaml <<'EOF' +session_name: dev +start_directory: ~/projects/myapp +windows: +- window_name: code + layout: main-horizontal + options: + main-pane-height: 60% + panes: + - vim + - bash +- window_name: server + panes: + - npm run dev # or cargo run, poetry run, etc. +- window_name: logs + panes: + - tail -f logs/app.log +EOF + +echo "Example tmuxp sessions created:" +echo " ~/.config/tmuxp/docker.yaml" +echo " ~/.config/tmuxp/dev.yaml" +echo "" +echo "Usage examples:" +echo " tmuxp load docker # from any dir" +echo " tmuxp load . # if .tmuxp.yaml exists in project" +echo " tmuxp ls # list available configs"