2

I'm currently started using tmux because of getting tired of term-mode, and I managed to shortcut in tmux to open current session output in emacs so I could search and select from it in emacs. I have the only problem - I wish for emacs buffer to display term session output with the same color highlighting - for directories to be blue e.g. As I understand it is doable since term-mode is able of that somehow. Can anyone point me how to copy text with such face overlays from terminal to emacs?

5
  • Are you using tmux in a terminal emulator outside Emacs or in term inside Emacs?
    – wvxvw
    Nov 13, 2016 at 8:23
  • in a terminal emulator outside.
    – sandric
    Nov 13, 2016 at 16:37
  • Does it show the output in any color at all, or is it all the same color? Typically, in terminal, colors are achieved by inserting so-called VT100 codes. In Emacs they are normally interpreted by something like comint-mode, but not necessary map to the same colors you'd see in a different terminal. Usually, your color scheme is responsible for the exact values of those colors.
    – wvxvw
    Nov 13, 2016 at 20:16
  • no color at all - right now I just copy from tmux with tmux save-buffer command. It just copies the text of tmux buffer. So my question is how to copy text with those keycodes and make emacs display colors, even if not matched precisely maybe.
    – sandric
    Nov 13, 2016 at 21:50
  • 1
    Ah, ok, now I understand... well, I'm sorry, I don't know. My guess is that you need to look in tmux documentation for clipboard formats it supports. If it could put vt100 codes in clipboard, you could achieve what you want.
    – wvxvw
    Nov 14, 2016 at 9:33

1 Answer 1

3

I found answer by my own - part of rendering ansi color codes in emacs originally answered here, I will double it here:

(require 'ansi-color)
(defun display-ansi-colors ()
    (interactive)
    (ansi-color-apply-on-region (point-min) (point-max)))

As for copying tmux buffer to with ansi codes for color - also was already answered here, and it here also:

bind H capture-pane -e \; save-buffer ~/tmux.hardcopy \; delete-buffer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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