Compare commits

...

10 Commits

Author SHA1 Message Date
chawley
5344d1a6ad Merge remote-tracking branch 'origin/tmux-menu-improved' into overdrive 2026-02-23 23:17:21 +00:00
26a847bc50 Preventing index collisions 2026-02-23 18:16:02 -05:00
82ca79307d Merge branch 'tmux-menu-improved' into overdrive 2026-02-21 21:24:21 -05:00
7c83a1154f Copied over .tmux.conf from main branch 2026-02-21 20:45:54 -05:00
bafcc00311 Changed name of config file 2026-02-21 20:43:32 -05:00
87dbb4e498 tmux-menu rewrite 2026-02-21 18:13:15 -05:00
chawley
d6f40c2a20 Specific config for WSL at work 2025-07-17 12:15:06 +00:00
chawley
0faaa30e8a Fixed colors on OverDrive terminal
fg/bg were reversed for a reason I am not interested in figuring out
right now.
2025-05-08 11:31:16 +00:00
chawley
e80189b264 Working .tmux.conf with overdrive 2025-05-07 17:16:59 +00:00
chawley
cf840864d1 overdrive branch
for its own .tmux.conf
2025-05-07 16:54:52 +00:00
4 changed files with 143 additions and 94 deletions

View File

@@ -71,7 +71,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
# Status bar style
set-option -g status-style bg=default,fg=colour8,bright # Set the background to default (transparent), foreground color, and brightness
set-option -g status-style bg=#000000,fg=colour8,bright # Set the background to default (transparent), foreground color, and brightness
#########################################
# Pane Appearance
@@ -97,10 +97,18 @@ set-option -g window-active-style bg=default # Background color for the active
# Window List Appearance
#########################################
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=colour0,bright
set-option -g window-status-format "#[fg=colour8,bg=default] #I:#W#[fg=colour8,bg=default]#{?window_activity_flag,#[fg=colour11]! ,}"
set-option -g window-status-current-format "#[fg=colour2,bg=colour0,bright] #I:#W#[fg=colour2,bg=colour0,nobold]"
#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
# Not active window
set-window-option -g window-status-format "#{?window_activity_flag,#[bg=#8802ad fg=#000000 bold],#[fg=#5e708c bg=default]}#I:#W"
# Active window
set-window-option -g window-status-current-format "#[bg=default fg=#059df5]● #I:#W"
#########################################
# Window Titles

108
tmux-menu.sh Executable file
View File

@@ -0,0 +1,108 @@
#!/usr/bin/env bash
#===============================================================================
#
# CREATED : 2026-02-21
# UPDATED : 2026-02-21
# USAGE :
# DESC : Hack tmux session launcher. Reads a YAML file to create a tmux # session with multiple windows and commands.
# NOTES :
# AUTHOR : chawley
#
#===============================================================================
# Path to the YAML configuration file
TMUX_CONFIG_FILE="${HOME}/.config/tmux-menu/tmux-sessions.yaml"
# Check for yq (YAML processor)
if ! command -v yq &> /dev/null; then
echo "Error: 'yq' command not found."
echo "Please install yq (https://github.com/mikefarah/yq) to use this script."
echo "Example: 'sudo snap install yq' or 'brew install yq'"
exit 1
fi
# check for command line argument
# Tips from:
# http://stackoverflow.com/questions/7832080/test-if-a-variable-is-set-in-bash-when-using-set-o-nounset
if [ -z "${1:-}" ]; then
session="undefined"
else
session=$1
fi
echo ""
echo ""
echo "##################################"
echo "TMUX Hack Session Launcher"
echo "##################################"
echo "Launching Session: $session"
# NO TMUX NESTING ALLOWED
if [ ! -z $TMUX ]; then
echo "You are in a session already. NO NESTING ALLOWED"
echo "-------------------------------------------------"
exit 1
fi
# if session is active, switch to it.
if tmux has-session -t "${session}" 2>/dev/null; then
echo "Session '${session}' already active. Attaching..."
tmux attach-session -t "${session}"
exit 0
fi
# Check if the config file exists
if [ ! -f "${TMUX_CONFIG_FILE}" ]; then
echo "Error: tmux session configuration file not found at '${TMUX_CONFIG_FILE}'."
echo "Please create it with your session definitions."
exit 1
fi
# Check if the requested session exists in the YAML file
if ! yq e ".sessions.${session}" "${TMUX_CONFIG_FILE}" &> /dev/null; then
echo "### ERROR No Such Session ###"
echo "Usage: $(basename "$0") <session_name>"
echo "Available Sessions from '${TMUX_CONFIG_FILE}':"
echo "---------------------------------------"
yq e '.sessions | keys | .[]' "${TMUX_CONFIG_FILE}" 2>/dev/null || echo "No sessions defined."
echo ""
echo "Active tmux Sessions:"
echo "---------------------"
tmux list-sessions 2>/dev/null || echo "No active sessions."
exit 1
fi
echo "Creating new session '${session}' from '${TMUX_CONFIG_FILE}'..."
# Get the number of windows for the session
num_windows=$(yq e ".sessions.${session}.windows | length" "${TMUX_CONFIG_FILE}")
if [[ "${num_windows}" -eq 0 ]]; then
echo "Error: Session '${session}' has no windows defined in '${TMUX_CONFIG_FILE}'."
exit 1
fi
# Create the first window (which also creates the session)
first_window_name=$(yq e ".sessions.${session}.windows[0].name" "${TMUX_CONFIG_FILE}")
first_window_command=$(yq e ".sessions.${session}.windows[0].command // \"\"" "${TMUX_CONFIG_FILE}")
if [[ -z "${first_window_command}" ]]; then
tmux new-session -d -s "${session}" -n "${first_window_name}"
else
tmux new-session -d -s "${session}" -n "${first_window_name}" "${first_window_command}"
fi
# Create subsequent windows
for ((i=1; i<num_windows; i++)); do
window_name=$(yq e ".sessions.${session}.windows[${i}].name" "${TMUX_CONFIG_FILE}")
window_command=$(yq e ".sessions.${session}.windows[${i}].command // \"\"" "${TMUX_CONFIG_FILE}")
if [[ -z "${window_command}" ]]; then
tmux new-window -t "${session}" -n "${window_name}"
else
tmux new-window -t "${session}" -n "${window_name}" "${window_command}"
fi
done
# Attach to the newly created session
tmux attach-session -t "${session}"

View File

@@ -1,89 +0,0 @@
#!/usr/bin/env bash
#===============================================================================
#
# FILE: tmux-menu.sh
#
# USAGE: ./tmux-menu.sh <session-name>
#
# DESCRIPTION: A hack script I wrote to help me manage pre-defined
# tmux-sessions
#
# OPTIONS:
# REQUIREMENTS: tmux
# NOTES: the cool down arrows in line 43? <ctrl-k> -v (see: digraphs)
# AUTHOR: C Hawley
# ORGANIZATION:
# CREATED: 2015-09
# REVISION: Mon 16 Oct 2017 05:28:00 PM EDT
#===============================================================================
# check for command line argument
# Tips from:
# http://stackoverflow.com/questions/7832080/test-if-a-variable-is-set-in-bash-when-using-set-o-nounset
if [ -z "${1:-}" ]; then
session="undefined"
else
session=$1
fi
echo ""
echo ""
echo "##################################"
echo "TMUX Hack Session Launcher"
echo "##################################"
echo "Launching Session: $session"
# NO TMUX NESTING ALLOWED
if [ ! -z $TMUX ]; then
echo "You are in a session already. NO NESTING ALLOWED"
echo "-------------------------------------------------"
exit 1
fi
tcheck=$(tmux list-sessions | grep -c "${session}") # check if session is active
# if session is active, switch to it. If not active but part of the list below,
# create it. Finally, if no session or undefined session is passed, give an
# error message and list the active sessions
# sample session definition
#
# case $session in
# analytics) # <- session name
# if [[ $tcheck == 0 ]]; then # <- check if it's already running
# tmux new-session -d -s analytics # <- if not, create it
# tmux rename-window 'localhost' # <- rename the first window (local)
# # ↓↓ define additional windows ↓↓
# tmux new-window -t:1 -n 'lasis01' 'exec ssh lasis01'
# tmux new-window -t:2 -n 'lasis01dev' 'exec ssh lasis01dev'
# tmux new-window -t:3 -n 'ldssbox01' 'exec ssh ldssbox01'
# tmux new-window -t:4 -n 'lpdprod01' 'exec ssh lpdprod01'
# tmux new-window -t:5 -n 'ldatalake01' 'exec ssh ldatalake01'
# tmux new-window -t:6 -n 'lsandbox' 'exec ssh lsandbox'
# fi
# tmux attach-session -t analytics # <- if window active, switch to it
# ;;
case $session in
mine)
if [[ $tcheck == 0 ]]; then
tmux new-session -d -s mine
tmux rename-window 'local(aristotle)'
tmux new-window -t 1 -n 'root@vps' 'exec ssh root@vps.example.org'
tmux new-window -t:2 -n 'chawley@phaedrus' 'exec ssh chawley@phaedrus'
tmux new-window -t:3 -n 'chawley@homer' 'exec ssh chawley@homer.simpsons.net'
fi
tmux attach-session -t mine
;;
# add more sessions here inside a case stanza. Start with a session name and end with ';;'
*)
echo "### ERROR No Such Session ###"
echo "Usage: tm <session_name>"
echo "Active Sessions:"
echo "----------------"
tmux list-sessions
;;
esac

22
tmux-sessions.yaml Normal file
View File

@@ -0,0 +1,22 @@
---
# tmux session definitions for tmux-menu.sh
# Place this file at ~/.config/tmux-menu/sessions.yaml
sessions:
mine:
windows:
- name: "local(aristotle)"
command: "" # Default to shell
- name: "root@vps"
command: "exec ssh root@vps.example.org"
- name: "chawley@phaedrus"
command: "exec ssh chawley@phaedrus"
- name: "chawley@homer"
command: "exec ssh chawley@homer.simpsons.net"
# Add more sessions here
# example_session:
# windows:
# - name: "local_shell"
# command: ""
# - name: "remote_server"
# command: "ssh user@remote"