I've bound a key to run a script with tmux's run-shell command, but I can't find any way to use color output.

  • normal ansi codes do not work, e.g.
    echo -e "\e[32mblah blah\e[0m"
  • tmux formatting does not work (nor did I expect it to), e.g.
    echo -e "#[fg=colour250]blah blah"
  • nor has anything else I've tried, like 256-color codes, e.g.
    printf "\x1b[38;5;57mblah blah"
  • if you can track it through tmux, then just write to its pty, or else, before you open tmux, export a variable like TMUX_PTY=$(tty) tmux ... and later write to that when you want it. – mikeserv Nov 15 '15 at 4:37

There is no workaround for run-shell, because tmux copies the data from the job in screen_write_vnputs, discarding any escape characters (as well as most other control characters). Here's the relevant chunk of code:

        if (*ptr == '\001')
            gc.attr ^= GRID_ATTR_CHARSET;
        else if (*ptr > 0x1f && *ptr < 0x7f) {
            screen_write_putc(ctx, &gc, *ptr);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.