unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* customizing dircolors doesn't take effect in emacs shell
@ 2012-01-07 21:28 Yuan Luo
  2012-01-08  0:12 ` Peter Dyballa
  0 siblings, 1 reply; 10+ messages in thread
From: Yuan Luo @ 2012-01-07 21:28 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

Hi,
So I have the following setting for dircolors in my ~/.bashrc. With my
customized ~/.dircolors file, a regular terminal shows the desired colors
upon ls in the shell. However, within the shell of emacs, it still shows
the default colors upon ls. This happens in emacs23, what am I missing?

if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval
"$(dircolors -b)"
    alias ls='ls --color=auto'
fi

Thanks,
Yuan

[-- Attachment #2: Type: text/html, Size: 540 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-07 21:28 customizing dircolors doesn't take effect in emacs shell Yuan Luo
@ 2012-01-08  0:12 ` Peter Dyballa
  2012-01-08  0:36   ` Yuan Luo
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Dyballa @ 2012-01-08  0:12 UTC (permalink / raw)
  To: Yuan Luo; +Cc: help-gnu-emacs


Am 7.1.2012 um 22:28 schrieb Yuan Luo:

> This happens in emacs23, what am I missing?

Put the useful shell aliases also in ~/.emacs_bash – this file is read in by the bash running in a *shell* buffer. (~/.emacs_bash can also be linked with ~/.bashrc. Maybe it's possible to customise the bash that it reads in ~/.bashrc.)

--
Greetings

  Pete

The future will be much better tomorrow.
				– George W. Bush




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-08  0:12 ` Peter Dyballa
@ 2012-01-08  0:36   ` Yuan Luo
  2012-01-08 10:50     ` Peter Dyballa
  0 siblings, 1 reply; 10+ messages in thread
From: Yuan Luo @ 2012-01-08  0:36 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

Hi Pete,
Thanks for your quick reply, I linked ~/.emacs_bash to ~/.bashrc but the
default color is still not changed. I read more about ~/.emacs_bash, it
seems to me emacs sends the content from this file to the interactive shell
upon starting. However, if I directly type "dircolors -b ~/.dircolors" in
emacs interactive shell, I got the following result:

LS_COLORS='';
export LS_COLORS

where as the same command typed in a regular system shell would yield the
desired LS_COLORS.

What could be the problem here?
Thanks,
Yuan

On Sat, Jan 7, 2012 at 7:12 PM, Peter Dyballa <Peter_Dyballa@web.de> wrote:

>
> Am 7.1.2012 um 22:28 schrieb Yuan Luo:
>
> > This happens in emacs23, what am I missing?
>
> Put the useful shell aliases also in ~/.emacs_bash – this file is read in
> by the bash running in a *shell* buffer. (~/.emacs_bash can also be linked
> with ~/.bashrc. Maybe it's possible to customise the bash that it reads in
> ~/.bashrc.)
>
> --
> Greetings
>
>  Pete
>
> The future will be much better tomorrow.
>                                – George W. Bush
>
>

[-- Attachment #2: Type: text/html, Size: 1493 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-08  0:36   ` Yuan Luo
@ 2012-01-08 10:50     ` Peter Dyballa
  2012-01-09  1:05       ` Yuan Luo
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Dyballa @ 2012-01-08 10:50 UTC (permalink / raw)
  To: Yuan Luo; +Cc: help-gnu-emacs


Am 8.1.2012 um 01:36 schrieb Yuan Luo:

> What could be the problem here?

Are in GNU Emacs' *shell* buffer any shell aliases defined? Is particularly your ls alias set? Which "ls" is found first for execution: your recursive alias definition (alias ls='ls --color=auto' – which "ls" is which?) or the ls programme?

--
Greetings

  Pete

Bake pizza not war!




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-08 10:50     ` Peter Dyballa
@ 2012-01-09  1:05       ` Yuan Luo
  2012-01-09  9:53         ` Peter Dyballa
  0 siblings, 1 reply; 10+ messages in thread
From: Yuan Luo @ 2012-01-09  1:05 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 933 bytes --]

Below is the output from 'alias' in an emacs shell

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal ||
echo error)" "$(history|tail -n1|sed -e
'\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

Anything noticeable?

Best,
Yuan

On Sun, Jan 8, 2012 at 5:50 AM, Peter Dyballa <Peter_Dyballa@web.de> wrote:

>
> Am 8.1.2012 um 01:36 schrieb Yuan Luo:
>
> > What could be the problem here?
>
> Are in GNU Emacs' *shell* buffer any shell aliases defined? Is
> particularly your ls alias set? Which "ls" is found first for execution:
> your recursive alias definition (alias ls='ls --color=auto' – which "ls" is
> which?) or the ls programme?
>
> --
> Greetings
>
>  Pete
>
> Bake pizza not war!
>
>

[-- Attachment #2: Type: text/html, Size: 1460 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-09  1:05       ` Yuan Luo
@ 2012-01-09  9:53         ` Peter Dyballa
  2012-01-09 16:43           ` Yuan Luo
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Dyballa @ 2012-01-09  9:53 UTC (permalink / raw)
  To: Yuan Luo; +Cc: help-gnu-emacs


Am 9.1.2012 um 02:05 schrieb Yuan Luo:

> alias l='ls -CF'
> alias la='ls -A'
> alias ll='ls -alF'
> alias ls='ls --color=auto'
> 
> Anything noticeable?

IMO it's not recommended to use the same symbol, "ls", left and right of the equals sign. I recommend to use the full pathname of the ls programme when this programme is meant.

Are all aliases from ~/.bashrc listed inside GNU Emacs?

Can you trace the execution of the ls alias?

Have you tried to use the more ANSI compliant "term" function/emulation?

It can be that you need to set up the *shell* buffer to actually show colours (*term* has it activated by default, by its more complete compliance to ANSI):

    (add-hook 'shell-mode-hook (lambda ()
    	(ansi-color-for-comint-mode-on)))

Check your GNU Emacs documentation on this topic!

--
Greetings

  Pete

The most exciting phrase to hear in science, the one that heralds new discoveries, is not "Eureka!" (I found it!) but "That's funny..."
				– Isaac Asimov




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-09  9:53         ` Peter Dyballa
@ 2012-01-09 16:43           ` Yuan Luo
  2012-01-09 16:48             ` Yuan Luo
  2012-01-09 20:56             ` Peter Dyballa
  0 siblings, 2 replies; 10+ messages in thread
From: Yuan Luo @ 2012-01-09 16:43 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1668 bytes --]

All aliases in ~/.bashrc are listed in emacs shells.
I already had have ansi-color-for-comint-mode-on set.
execution of ls traces to /bin/ls

Maybe i was not clear in the beginning, the emacs shell can show colors,
but not to my customization, for example, I customized it to show
executables in purple, it still show them in red. While a regular terminal
shows the desirable purple color for executables (as in below, left is
regular terminal, right is emacs shell).

On Mon, Jan 9, 2012 at 4:53 AM, Peter Dyballa <Peter_Dyballa@web.de> wrote:

>
> Am 9.1.2012 um 02:05 schrieb Yuan Luo:
>
> > alias l='ls -CF'
> > alias la='ls -A'
> > alias ll='ls -alF'
> > alias ls='ls --color=auto'
> >
> > Anything noticeable?
>
> IMO it's not recommended to use the same symbol, "ls", left and right of
> the equals sign. I recommend to use the full pathname of the ls programme
> when this programme is meant.
>
> Are all aliases from ~/.bashrc listed inside GNU Emacs?
>
> Can you trace the execution of the ls alias?
>
> Have you tried to use the more ANSI compliant "term" function/emulation?
>
> It can be that you need to set up the *shell* buffer to actually show
> colours (*term* has it activated by default, by its more complete
> compliance to ANSI):
>
>    (add-hook 'shell-mode-hook (lambda ()
>        (ansi-color-for-comint-mode-on)))
>
> Check your GNU Emacs documentation on this topic!
>
> --
> Greetings
>
>  Pete
>
> The most exciting phrase to hear in science, the one that heralds new
> discoveries, is not "Eureka!" (I found it!) but "That's funny..."
>                                – Isaac Asimov
>
>

[-- Attachment #2: Type: text/html, Size: 56235 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-09 16:43           ` Yuan Luo
@ 2012-01-09 16:48             ` Yuan Luo
  2012-01-09 20:56             ` Peter Dyballa
  1 sibling, 0 replies; 10+ messages in thread
From: Yuan Luo @ 2012-01-09 16:48 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 1873 bytes --]

Sorry forgot attaching picture. Here it is.

Best,
Yuan
On Mon, Jan 9, 2012 at 11:43 AM, Yuan Luo <yuan.hypnos.luo@gmail.com> wrote:

> All aliases in ~/.bashrc are listed in emacs shells.
> I already had have ansi-color-for-comint-mode-on set.
> execution of ls traces to /bin/ls
>
> Maybe i was not clear in the beginning, the emacs shell can show colors,
> but not to my customization, for example, I customized it to show
> executables in purple, it still show them in red. While a regular terminal
> shows the desirable purple color for executables (as in below, left is
> regular terminal, right is emacs shell).
>
>
> On Mon, Jan 9, 2012 at 4:53 AM, Peter Dyballa <Peter_Dyballa@web.de>wrote:
>
>>
>> Am 9.1.2012 um 02:05 schrieb Yuan Luo:
>>
>> > alias l='ls -CF'
>> > alias la='ls -A'
>> > alias ll='ls -alF'
>> > alias ls='ls --color=auto'
>> >
>> > Anything noticeable?
>>
>> IMO it's not recommended to use the same symbol, "ls", left and right of
>> the equals sign. I recommend to use the full pathname of the ls programme
>> when this programme is meant.
>>
>> Are all aliases from ~/.bashrc listed inside GNU Emacs?
>>
>> Can you trace the execution of the ls alias?
>>
>> Have you tried to use the more ANSI compliant "term" function/emulation?
>>
>> It can be that you need to set up the *shell* buffer to actually show
>> colours (*term* has it activated by default, by its more complete
>> compliance to ANSI):
>>
>>    (add-hook 'shell-mode-hook (lambda ()
>>        (ansi-color-for-comint-mode-on)))
>>
>> Check your GNU Emacs documentation on this topic!
>>
>> --
>> Greetings
>>
>>  Pete
>>
>> The most exciting phrase to hear in science, the one that heralds new
>> discoveries, is not "Eureka!" (I found it!) but "That's funny..."
>>                                – Isaac Asimov
>>
>>
>

[-- Attachment #1.2: Type: text/html, Size: 2743 bytes --]

[-- Attachment #2: regular_vs_emacs_shell.png --]
[-- Type: image/png, Size: 45722 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-09 16:43           ` Yuan Luo
  2012-01-09 16:48             ` Yuan Luo
@ 2012-01-09 20:56             ` Peter Dyballa
  2012-01-15 22:34               ` Yuan Luo
  1 sibling, 1 reply; 10+ messages in thread
From: Peter Dyballa @ 2012-01-09 20:56 UTC (permalink / raw)
  To: Yuan Luo; +Cc: help-gnu-emacs


Am 9.1.2012 um 17:43 schrieb Yuan Luo:

> All aliases in ~/.bashrc are listed in emacs shells.
> I already had have ansi-color-for-comint-mode-on set.
> execution of ls traces to /bin/ls

Does it work when you use

	/bin/ls --color=auto /bin
	/bin/ls --color /bin

manually and directly?

My manual page explains:

	With --color=auto, ls emits color codes only when standard output is connected to a terminal. The LS_COLORS environment variable can change the settings. Use the dircolors command to set it.

There is a chance that LS_COLORS hinders ls, it's also possible that in *shell* buffer standard output is not connected to a terminal. The latter seems to be true for me on Mac OS X (10.6.8, Snow Leopard). So by omitting the "=auto" should make your aliases work.

--
Greetings

  Pete

Bake pizza not war!




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: customizing dircolors doesn't take effect in emacs shell
  2012-01-09 20:56             ` Peter Dyballa
@ 2012-01-15 22:34               ` Yuan Luo
  0 siblings, 0 replies; 10+ messages in thread
From: Yuan Luo @ 2012-01-15 22:34 UTC (permalink / raw)
  To: Peter Dyballa; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

I found the solution:
adding a line TERM=dumb in the ~/.dircolors file did the trick, as emacs
inferior mode shell type is dumb.

Thanks for all the help getting me close to the answer!

Best,
Yuan

On Mon, Jan 9, 2012 at 3:56 PM, Peter Dyballa <Peter_Dyballa@web.de> wrote:

>
> Am 9.1.2012 um 17:43 schrieb Yuan Luo:
>
> > All aliases in ~/.bashrc are listed in emacs shells.
> > I already had have ansi-color-for-comint-mode-on set.
> > execution of ls traces to /bin/ls
>
> Does it work when you use
>
>        /bin/ls --color=auto /bin
>        /bin/ls --color /bin
>
> manually and directly?
>
> My manual page explains:
>
>        With --color=auto, ls emits color codes only when standard output
> is connected to a terminal. The LS_COLORS environment variable can change
> the settings. Use the dircolors command to set it.
>
> There is a chance that LS_COLORS hinders ls, it's also possible that in
> *shell* buffer standard output is not connected to a terminal. The latter
> seems to be true for me on Mac OS X (10.6.8, Snow Leopard). So by omitting
> the "=auto" should make your aliases work.
>
> --
> Greetings
>
>  Pete
>
> Bake pizza not war!
>
>

[-- Attachment #2: Type: text/html, Size: 1597 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-01-15 22:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-07 21:28 customizing dircolors doesn't take effect in emacs shell Yuan Luo
2012-01-08  0:12 ` Peter Dyballa
2012-01-08  0:36   ` Yuan Luo
2012-01-08 10:50     ` Peter Dyballa
2012-01-09  1:05       ` Yuan Luo
2012-01-09  9:53         ` Peter Dyballa
2012-01-09 16:43           ` Yuan Luo
2012-01-09 16:48             ` Yuan Luo
2012-01-09 20:56             ` Peter Dyballa
2012-01-15 22:34               ` Yuan Luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).