Updated home and work conf files
Added tmi.sh script Updated README
This commit is contained in:
@@ -97,11 +97,6 @@ set-window-option -g window-active-style bg=default # Background color for the
|
|||||||
# Window List Appearance
|
# Window List Appearance
|
||||||
#########################################
|
#########################################
|
||||||
|
|
||||||
#set-window-option -g window-status-style fg=blue # Or your preferred inactive style
|
|
||||||
#set-window-option -g window-status-format "#[fg=blue] #I:#W#[fg=blue]#{?window_activity_flag,#[fg=yellow bg=default]!,}"
|
|
||||||
#set-window-option -g window-status-current-style fg=green,bright
|
|
||||||
#set-window-option -g window-status-current-format "#[fg=green,bright]● #I:#W ●#[fg=green]"
|
|
||||||
|
|
||||||
# Stolen from https://github.com/mhartington/dotfiles/blob/main/config/tmux/tmux-status.conf
|
# Stolen from https://github.com/mhartington/dotfiles/blob/main/config/tmux/tmux-status.conf
|
||||||
|
|
||||||
# Not active window
|
# Not active window
|
||||||
@@ -116,4 +111,3 @@ set-window-option -g window-status-current-format "#[bg=default fg=#7cfc00]● #
|
|||||||
|
|
||||||
set-option -g set-titles on # Enable automatic window titles
|
set-option -g set-titles on # Enable automatic window titles
|
||||||
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # Format string for window titles (hostname:session.window_index.pane_index window_number window_name)
|
set-option -g set-titles-string '#H:#S.#I.#P #W #T' # Format string for window titles (hostname:session.window_index.pane_index window_number window_name)
|
||||||
|
|
||||||
|
|||||||
+5
-9
@@ -59,6 +59,7 @@ set-option -g visual-activity on # Enable visual notification of activity in ot
|
|||||||
#########################################
|
#########################################
|
||||||
|
|
||||||
set-option -g status on # Turn the status bar on
|
set-option -g status on # Turn the status bar on
|
||||||
|
set-option -g status-position top # Put the Status Bar on top of the screen
|
||||||
set-option -g status-interval 5 # Set the status bar update frequency to 5 seconds
|
set-option -g status-interval 5 # Set the status bar update frequency to 5 seconds
|
||||||
set-option -g status-justify centre # Justify the window list to the left
|
set-option -g status-justify centre # Justify the window list to the left
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ set-option -g status-right-length 60 # Set the maximum length of the right
|
|||||||
set-option -g status-right "S:#S W:#I P:#P | %b %d %H:%M" # Display session name, window index, pane index, and the date/time on the right
|
set-option -g status-right "S:#S W:#I P:#P | %b %d %H:%M" # Display session name, window index, pane index, and the date/time on the right
|
||||||
|
|
||||||
# Status bar style
|
# Status bar style
|
||||||
set-option -g status-style bg=#000000,fg=colour8,bright # Set the background to default (transparent), foreground color, and brightness
|
set-option -g status-style bg=#000000,fg=grey # Set the background to default (transparent), foreground color, and brightness
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Pane Appearance
|
# Pane Appearance
|
||||||
@@ -90,22 +91,17 @@ set-option -g message-style bg=default,fg=colour13 # Style for messages displaye
|
|||||||
# Window Appearance
|
# Window Appearance
|
||||||
#########################################
|
#########################################
|
||||||
|
|
||||||
set-option -g window-style bg=default # Default background color for windows
|
set-window-option -g window-style bg=default # Default background color for windows
|
||||||
set-option -g window-active-style bg=default # Background color for the active window
|
set-window-option -g window-active-style bg=default # Background color for the active window
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Window List Appearance
|
# Window List Appearance
|
||||||
#########################################
|
#########################################
|
||||||
|
|
||||||
#set-option -g window-status-current-format "#[fg=colour2,bg=colour0]● #I:#W ●#[fg=colour2,bg=colour0]"
|
|
||||||
#set-option -g window-status-style fg=colour8,bg=default # Or your preferred inactive style
|
|
||||||
#set-option -g window-status-current-style fg=colour2,bg=default,bright
|
|
||||||
#set-option -g window-status-format "#[fg=colour8,bg=default] #I:#W#[fg=colour8,bg=default]#{?window_activity_flag,#[fg=colour11]! ,}"
|
|
||||||
|
|
||||||
# Stolen from https://github.com/mhartington/dotfiles/blob/main/config/tmux/tmux-status.conf
|
# Stolen from https://github.com/mhartington/dotfiles/blob/main/config/tmux/tmux-status.conf
|
||||||
|
|
||||||
# Not active window
|
# Not active window
|
||||||
set-window-option -g window-status-format "#{?window_activity_flag,#[bg=#8802ad fg=#000000 bold],#[fg=#5e708c bg=default]}#I:#W"
|
set-window-option -g window-status-format "#{?window_activity_flag,#[bg=#ffff00 fg=#000000 bold],#[fg=#228b22 bg=default]}#I:#W"
|
||||||
|
|
||||||
# Active window
|
# Active window
|
||||||
set-window-option -g window-status-current-format "#[bg=default fg=#059df5]● #I:#W"
|
set-window-option -g window-status-current-format "#[bg=default fg=#059df5]● #I:#W"
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
---
|
---
|
||||||
CREATED : 2026-03-03
|
created: 2015-09-09
|
||||||
UPDATED : 2026-03-03
|
updated: 2026-07-21
|
||||||
AUTHOR : chawley
|
author: chawley
|
||||||
---
|
---
|
||||||
|
|
||||||
|
#readme
|
||||||
# TMUX Hack Session Launcher
|
# TMUX Hack Session Launcher
|
||||||
|
|
||||||
A Bash script designed to manage and automate pre-defined tmux-sessions. This script allows you to launch complex development or administration environments - complete with multiple windows and SSH connections - using a single command.
|
A Bash script designed to manage and automate pre-defined tmux-sessions. This script allows you to launch complex development or administration environments - complete with multiple windows and SSH connections - using a single command.
|
||||||
@@ -32,6 +33,7 @@ A Bash script designed to manage and automate pre-defined tmux-sessions. This sc
|
|||||||
1. Copy the script to a directory in your `$PATH` (e.g., `~/bin` or `/usr/local/bin`).
|
1. Copy the script to a directory in your `$PATH` (e.g., `~/bin` or `/usr/local/bin`).
|
||||||
2. Rename it to something short, like `tm`.
|
2. Rename it to something short, like `tm`.
|
||||||
3. Make the script executable:
|
3. Make the script executable:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
chmod +x ~/bin/tm
|
chmod +x ~/bin/tm
|
||||||
```
|
```
|
||||||
@@ -67,4 +69,16 @@ To add a new session, add a new case stanza inside the `case $session in` block.
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Script Variables
|
### Script Variables
|
||||||
|
|
||||||
- `TMUX_CONF`: Defaults to `$HOME/.tmux.conf`. Modify this variable if your configuration file is located elsewhere.
|
- `TMUX_CONF`: Defaults to `$HOME/.tmux.conf`. Modify this variable if your configuration file is located elsewhere.
|
||||||
|
|
||||||
|
## Tmux Menu Improved (TMI)
|
||||||
|
|
||||||
|
A vibe-coded improvement on the original
|
||||||
|
### Key Improvements & Refactor Notes
|
||||||
|
|
||||||
|
- **Robust Session Detection (`tmux has-session`):** Replaced `tmux list-sessions | grep -c` with `tmux has-session -t "=${session}"`. Using exact match targeting (`=`) prevents substring false positives (e.g., matching `mine` against `mine-dev` or log strings) and eliminates pipe subshell overhead.
|
||||||
|
- **Declarative Data Structure:** Session definitions are separated from the initialization logic using an associative array (`SESSIONS`). Adding a new layout only requires defining a new key and window matrix, removing repetitive `tmux new-window` boilerplates.
|
||||||
|
- **Process Handover via `exec`:** Replaced subshell execution of `tmux attach-session` with `exec tmux ...`. This replaces the bash script process with the tmux client process directly, eliminating an orphaned shell process remaining in memory while attached.
|
||||||
|
- **Strict Shell Hygiene:** Added `set -euo pipefail` and proper variable quoting to prevent unhandled failures or field splitting errors. redirected operational error output to `stderr` (`>&2`).
|
||||||
|
- **Interactive Fallback (`fzf`):** If invoked without arguments (`tm`), the script checks for `fzf` in `$PATH`. If present, it serves an interactive fuzzy selector of configured session keys rather than instantly printing an error.
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
# created: 2015-09-09
|
||||||
|
# updated: 2026-07-21
|
||||||
|
# usage: tm [session_name]
|
||||||
|
# desc: Interactive and declarative tmux session manager.
|
||||||
|
# notes:
|
||||||
|
# author: chawley
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly TMUX_CONF="${HOME}/.tmux.conf"
|
||||||
|
|
||||||
|
# Ensure we are not nesting tmux sessions
|
||||||
|
if [[ -n "${TMUX:-}" ]]; then
|
||||||
|
echo "Error: Already inside a tmux session. Nesting is disabled." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define session layouts as data maps: "window_index:window_name:command"
|
||||||
|
# Index 1 is reserved for the initial session window (renamed inline).
|
||||||
|
declare -A SESSIONS
|
||||||
|
|
||||||
|
SESSIONS[mine]="
|
||||||
|
1:local(phansible@aamon):
|
||||||
|
2:phansible@overlook:exec ssh phansible@overlook.tailc38dc9.ts.net
|
||||||
|
3:weechat:exec ssh overlook-ts && docker start weechat && docker attach weechat
|
||||||
|
4:chawley@overlook:exec ssh overlook-ts
|
||||||
|
5:chawley@shawshank:exec ssh shawshank-ts
|
||||||
|
6:root@derry:exec ssh derry-ts
|
||||||
|
"
|
||||||
|
|
||||||
|
list_active_sessions() {
|
||||||
|
echo "----------------------------------"
|
||||||
|
echo "Active Tmux Sessions"
|
||||||
|
echo "----------------------------------"
|
||||||
|
if tmux has-session 2>/dev/null; then
|
||||||
|
tmux list-sessions
|
||||||
|
else
|
||||||
|
echo "No active tmux sessions."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Resolve target session (argument or fuzzy picker via fzf if available)
|
||||||
|
session="${1:-}"
|
||||||
|
|
||||||
|
if [[ -z "${session}" ]]; then
|
||||||
|
if command -v fzf &>/dev/null; then
|
||||||
|
session=$(printf '\%s\n' "${!SESSIONS[@]}" | fzf --prompt="Select Tmux Session > " --height=10 --reverse || true)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${session}" ]]; then
|
||||||
|
echo "Usage: $(basename "$0") <session_name>"
|
||||||
|
echo ""
|
||||||
|
list_active_sessions
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${SESSIONS[$session]:-}" ]]; then
|
||||||
|
echo "Error: Unknown session layout '${session}'" >&2
|
||||||
|
echo ""
|
||||||
|
list_active_sessions
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Attach if session exists; otherwise construct and attach
|
||||||
|
if tmux has-session -t "=${session}" 2>/dev/null; then
|
||||||
|
echo "Attaching to existing session: ${session}"
|
||||||
|
exec tmux -f "${TMUX_CONF}" attach-session -t "=${session}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building session: ${session}"
|
||||||
|
|
||||||
|
# Process layout line by line
|
||||||
|
first_window=true
|
||||||
|
while IFS=':' read -r idx name cmd; do
|
||||||
|
[[ -z "${idx}" ]] && continue
|
||||||
|
|
||||||
|
if [[ "${first_window}" == true ]]; then
|
||||||
|
tmux -f "${TMUX_CONF}" new-session -d -s "${session}" -n "${name}"
|
||||||
|
if [[ -n "${cmd}" ]]; then
|
||||||
|
tmux send-keys -t "=${session}:1" "${cmd}" C-m
|
||||||
|
fi
|
||||||
|
first_window=false
|
||||||
|
else
|
||||||
|
if [[ -n "${cmd}" ]]; then
|
||||||
|
tmux -f "${TMUX_CONF}" new-window -t "=${session}:${idx}" -n "${name}" "${cmd}"
|
||||||
|
else
|
||||||
|
tmux -f "${TMUX_CONF}" new-window -t "=${session}:${idx}" -n "${name}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done <<< "${SESSIONS[$session]}"
|
||||||
|
|
||||||
|
exec tmux -f "${TMUX_CONF}" attach-session -t "=${session}"
|
||||||
Reference in New Issue
Block a user