[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Examining the output of a shell command?
From: |
Pascal J. Bourguignon |
Subject: |
Re: Examining the output of a shell command? |
Date: |
Mon, 29 Jun 2015 14:08:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Raffaele Ricciardi <rfflrccrd@gmail.com> writes:
> On 28/06/15 15:57, Pascal J. Bourguignon wrote:
>> (shell-command-to-string "echo $RED hello $NORMAL")
>> --> "[31m hello [0m> "
>
> Hence, how could I capture a colorized output in Emacs as in a Bash
> session?
This is an entirely different question, isn't it.
In *shell* and other comint based modes, you can activate interpretion
of ANSI escape codes for colorizing with
M-x ansi-color-for-comint-mode-on RET
You can process the string with ansi-color-apply:
(ansi-color-apply
(shell-command-to-string "echo $RED hello $YELLOW world $NORMAL"))
--> #(" hello world
" 0 7 (font-lock-face (foreground-color . "red")) 7 14 (font-lock-face
(foreground-color . "yellow")))
(insert (ansi-color-apply
(shell-command-to-string "echo $RED hello $YELLOW world $NORMAL")))
hello world
^red ^yellow
--> nil
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
- Re: Examining the output of a shell command?, (continued)
- Message not available
- Re: Examining the output of a shell command?, Raffaele Ricciardi, 2015/06/28
- Re: Examining the output of a shell command?, Eli Zaretskii, 2015/06/28
- Message not available
- Re: Examining the output of a shell command?, Raffaele Ricciardi, 2015/06/28
- Re: Examining the output of a shell command?, Eli Zaretskii, 2015/06/28
- Message not available
- Re: Examining the output of a shell command?, Raffaele Ricciardi, 2015/06/28
- Re: Examining the output of a shell command?, Pascal J. Bourguignon, 2015/06/28
- Re: Examining the output of a shell command?, Emanuel Berg, 2015/06/28
- Message not available
- Re: Examining the output of a shell command?, Pascal J. Bourguignon, 2015/06/29
Message not available