Instantly identify which tmux sessions are connected or disconnected with visual styling in the azlin list command.
The azlin list command now displays tmux session connection status using visual text styling:
- Connected Sessions: Appear in bold text to stand out
- Disconnected Sessions: Appear in dim text to de-emphasize
- Zero Overhead: Uses existing SSH connection, no additional network calls
This eliminates the need to SSH into each VM and run tmux list-sessions manually to find where your active work is located.
Tmux session status monitoring solves several workflow challenges:
You have multiple VMs with tmux sessions and need to find where your active debugging session is running.
Without connection status: SSH into each VM and run tmux list-sessions to check connection status.
With connection status: Run azlin list and connected sessions appear in bold - your active work jumps out immediately.
You've disconnected from a VM but can't remember which one still has your tmux session running.
Without connection status: Try to remember which VM you were using, or check each one manually.
With connection status: Disconnected sessions appear in dim text - quickly scan the list to find orphaned sessions that need attention.
You're working across multiple VMs with different tasks in tmux and need to see the overall state at a glance.
Without connection status: Keep mental notes or a separate document tracking which sessions are active.
With connection status: One azlin list command shows the complete picture - bold for active, dim for backgrounded.
Multiple team members are using shared VMs with tmux and you need to see which sessions are currently occupied.
Without connection status: Coordinate manually or risk attaching to an active session and disrupting someone's work.
With connection status: Connected (bold) sessions indicate someone is actively using them - avoid conflicts.
Connection status is detected through an enhanced tmux query that includes attachment information:
1. SSH to VM (reuses existing connection)
└─▶ Already connecting for VM status check - zero additional overhead
2. Run enhanced tmux query
└─▶ tmux list-sessions -F "#{session_name}:#{session_attached}:#{session_windows}:#{session_created}"
3. Parse attachment status
├─▶ session_attached=1: Session is connected → Apply bold markup
└─▶ session_attached=0: Session is disconnected → Apply dim markup
4. Apply Rich library styling
├─▶ Connected: [bold]session-name[/bold]
└─▶ Disconnected: [dim]session-name[/dim]
Key Features:
- Zero overhead: Uses existing SSH connection from VM status check
- Graceful fallback: If enhanced format fails, parser automatically falls back to old format
- Terminal-agnostic: Works across all terminals through Rich library
- Format-aware: Detects new vs old tmux output format automatically
| Operation | Overhead | Notes |
|---|---|---|
| Connection status detection | 0 seconds | Reuses existing SSH connection |
| Tmux query | <50ms per VM | Minimal query overhead |
| Format detection | Automatic | Parser handles both old and new formats |
| Rendering | <1ms | Rich library handles terminal capabilities |
The feature handles various edge cases elegantly:
- Tmux not installed: No session display (same as before)
- Tmux query fails: Falls back to old parser format
- Terminal doesn't support styling: Falls back to plain text
- No tmux sessions: Clean display with no session data
Basic VM listing with tmux connection status:
azlin listOutput:
Listing VMs in resource group: dev-rg
==================================================================================================
NAME STATUS IP REGION SIZE TMUX SESSIONS
==================================================================================================
dev-vm-001 Running 20.123.45.67 eastus Standard_D4s_v3 main, debug
dev-vm-002 Running 20.123.45.68 westus2 Standard_D2s_v3 training
dev-vm-003 Running 20.123.45.69 eastus Standard_D2s_v3 (no sessions)
==================================================================================================
Total: 3 VMs | 12 vCPUs | 24 GB memory in use
Visual Styling (as seen in terminal):
dev-vm-001: main appears bold (connected),debugappears dim (disconnected)dev-vm-002:trainingappears dim (disconnected)dev-vm-003: No sessions, shows "(no sessions)"
You need to find which VM has your active debugging session:
azlin listWhat you see:
- VM
dev-vm-001shows session "debug" in bold - Other sessions appear dim
- Result: You immediately know
dev-vm-001has your active session
You want to clean up orphaned sessions that are no longer needed:
azlin listWhat you see:
- Multiple VMs with dim session names
- These are all disconnected sessions
- Result: Identify cleanup candidates at a glance
Combine connection status with latency for complete operational view:
azlin list --with-latencyOutput:
Listing VMs in resource group: dev-rg
============================================================================================================
NAME STATUS IP LATENCY REGION SIZE TMUX SESSIONS
============================================================================================================
dev-vm-001 Running 20.123.45.67 45ms eastus Standard_D4s_v3 main, debug
dev-vm-002 Running 20.123.45.68 180ms westus2 Standard_D2s_v3 training
============================================================================================================
Total: 2 VMs | 8 vCPUs | 16 GB memory in use
Visual Styling:
- Low latency VM (45ms) with bold session indicates optimal target for interactive work
- High latency VM (180ms) with dim sessions suggests backgrounded work
The feature enhances the existing tmux query format:
Old format (still supported via fallback):
tmux list-sessions
# Output: session_name: 3 windows (created Thu Dec 19 10:30:00 2024)
New enhanced format:
tmux list-sessions -F "#{session_name}:#{session_attached}:#{session_windows}:#{session_created}"
# Output: main:1:3:1734608200
# debug:0:5:1734611100
The parser automatically detects which format is returned and processes accordingly.
Styling uses Rich library markup that's terminal-agnostic:
# Connected session (bold)
rich_text = "[bold]session-name[/bold]"
# Disconnected session (dim)
rich_text = "[dim]session-name[/dim]"Rich library automatically:
- Detects terminal capabilities
- Falls back to plain text for unsupported terminals
- Handles color/no-color environments
- Renders consistently across macOS, Linux, Windows
Supported tmux versions: 1.8+ (most common installations)
Terminal compatibility: Any terminal that supports:
- Bold text (most modern terminals)
- Dim/faint text (fallback to normal if unsupported)
Platforms:
- macOS (Terminal.app, iTerm2, Alacritty, etc.)
- Linux (GNOME Terminal, Konsole, xterm, etc.)
- Windows (Windows Terminal, WSL terminals)
Zero performance impact because:
- Query piggybacks on existing SSH connection
- Enhanced format query has same execution time as old format
- Rich markup parsing happens locally (no network overhead)
- Fallback detection adds <1ms parsing time
Symptom: All sessions appear the same without bold/dim styling.
Cause: Terminal doesn't support text styling.
Solution:
- Use a modern terminal (iTerm2, Windows Terminal, etc.)
- Check terminal color support:
echo $TERM - Expected values:
xterm-256color,screen-256color
Workaround: Connection status is still accurate, just not visually styled.
Symptom: A session appears connected (bold) but you're not attached, or vice versa.
Cause: Query format mismatch or stale session data.
Solution:
# SSH to the VM and verify manually
ssh azureuser@<vm-ip>
tmux list-sessions
# Check for zombie sessions
tmux kill-session -t <session-name>Likely causes:
- Tmux server restart needed
- Network interruption left stale session
- Multiple users on same VM
Symptom: Parser falls back to old format and logs warning.
Cause: Tmux version doesn't support enhanced format query.
Solution: Update tmux on the VM:
# Ubuntu/Debian
sudo apt update && sudo apt install tmux
# RHEL/CentOS
sudo yum update tmux
# macOS
brew upgrade tmuxImpact: Feature still works but without connection status detection.
Symptom: Tmux sessions column shows "(no sessions)" even though sessions exist.
Cause: SSH connection unable to query tmux.
Debugging steps:
# Verify tmux is installed
ssh azureuser@<vm-ip> which tmux
# Check if tmux server is running
ssh azureuser@<vm-ip> tmux list-sessions
# Check socket permissions
ssh azureuser@<vm-ip> ls -la /tmp/tmux-*Common fixes:
- Restart tmux server:
tmux kill-server && tmux - Fix socket permissions:
chmod 700 /tmp/tmux-$(id -u)
Symptom: azlin list seems slower with 20+ VMs.
Cause: SSH connections to many VMs take time (not related to this feature).
Solution: Query specific resource groups or regions:
# Filter by region
azlin list --region eastus
# Filter by resource group
azlin list --rg dev-rg
# Use compact format (faster)
azlin list --compactNote: Tmux connection status adds <50ms per VM, negligible compared to SSH connection time (~500ms-2s per VM).
- Memory and Latency Monitoring - See VM resource allocation and network latency
- VM Lifecycle Automation - Automatic status checking that enables this feature
- Hostname and Session Name in Status Line - Complementary feature showing VM info in tmux itself
- azlin Quick Reference - Complete command reference
- How to Troubleshoot Connection Issues - SSH and tmux debugging
- API Reference - list command - Technical details