Hi, I'm attaching a small patch. It adds a token to the status line format which will indicate whether you're in command-mode or not.
I often use tmux nested, sometimes up to three levels deep. When I have three status lines at the bottom of my window, sending commands into the inner-most tmux session can be mentally taxing. (I know, "So don't do that!", but trust me that my use case isn't entirely pathological). With this patch and the token in my format string, it is easy to see which (if any) nested session is in the middle of a prefixed command sequence. It helps. I use it in my status-left format, like this: set -g status-left "#^" Which sets the first char of my status line to "_" in normal mode, or "^" when the command prefix is acive. In this patch, I'm calling server_status_client() any time c->flags might be twiddled in the CLIENT_PREFIX position. It would be better to wrap the flag set/clear in some code that checks for changes and only marks the status line for redrawing if needed. Posted in case anyone else finds it useful. Thanks for tmux! Andrew Reynhout ---------------------------------------- diff -ru tmux-1.6-dist/server-client.c tmux-1.6/server-client.c --- tmux-1.6-dist/server-client.c 2012-01-23 07:24:01.000000000 -0500 +++ tmux-1.6/server-client.c 2012-08-09 14:45:51.000000000 -0400 @@ -366,8 +366,10 @@ /* No previous prefix key. */ if (!(c->flags & CLIENT_PREFIX)) { - if (isprefix) + if (isprefix) { c->flags |= CLIENT_PREFIX; + server_status_client(c); + } else { /* Try as a non-prefix key binding. */ if ((bd = key_bindings_lookup(key)) == NULL) { @@ -381,12 +383,15 @@ /* Prefix key already pressed. Reset prefix and lookup key. */ c->flags &= ~CLIENT_PREFIX; + server_status_client(c); if ((bd = key_bindings_lookup(key | KEYC_PREFIX)) == NULL) { /* If repeating, treat this as a key, else ignore. */ if (c->flags & CLIENT_REPEAT) { c->flags &= ~CLIENT_REPEAT; - if (isprefix) + if (isprefix) { c->flags |= CLIENT_PREFIX; + server_status_client(c); + } else if (!(c->flags & CLIENT_READONLY)) window_pane_key(wp, c->session, key); } @@ -396,8 +401,10 @@ /* If already repeating, but this key can't repeat, skip it. */ if (c->flags & CLIENT_REPEAT && !bd->can_repeat) { c->flags &= ~CLIENT_REPEAT; - if (isprefix) + if (isprefix) { c->flags |= CLIENT_PREFIX; + server_status_client(c); + } else if (!(c->flags & CLIENT_READONLY)) window_pane_key(wp, c->session, key); return; @@ -407,6 +414,7 @@ xtimeout = options_get_number(&c->session->options, "repeat-time"); if (xtimeout != 0 && bd->can_repeat) { c->flags |= CLIENT_PREFIX|CLIENT_REPEAT; + server_status_client(c); tv.tv_sec = xtimeout / 1000; tv.tv_usec = (xtimeout % 1000) * 1000L; @@ -534,8 +542,10 @@ { struct client *c = data; - if (c->flags & CLIENT_REPEAT) + if (c->flags & CLIENT_REPEAT) { c->flags &= ~(CLIENT_PREFIX|CLIENT_REPEAT); + server_status_client(c); + } } /* Check if client should be exited. */ diff -ru tmux-1.6-dist/status.c tmux-1.6/status.c --- tmux-1.6-dist/status.c 2012-01-20 16:20:36.000000000 -0500 +++ tmux-1.6/status.c 2012-08-09 14:47:12.000000000 -0400 @@ -402,6 +402,13 @@ if ((ptr = status_find_job(c, iptr)) == NULL) return; goto do_replace; + case '^': + if (c->flags & CLIENT_PREFIX) + xsnprintf(tmp, sizeof tmp, "^"); + else + xsnprintf(tmp, sizeof tmp, "_"); + ptr = tmp; + goto do_replace; case 'D': xsnprintf(tmp, sizeof tmp, "%%%u", wp->id); ptr = tmp; ---------------------------- EOF -- reynh...@quesera.com ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users