WelcomeUser Guide
ToSPrivacyCanary
DonateBugsLicense

©2025 Poal.co

560

I'm too much of a smooth brain to figure what I'm doing wrong here. I have the following in my bashrc:

alias ls="command ls --color=always --classify -v -C --group-directories-first --show-control-chars --sort=extension"

cd () { command cd "$@" && ls ; }

Now, when I "cd ~/some/dir", my customized view is properly displayed. If I manually 'ls' in that dir or any other dir, my customized view is lost. Any ideas what could cause that?

While I have your ear, somewhat off topic, why is it that when I write the 'ls' alias as a function, bash shits itself? When I write it like so:

ls () { command ls --color=always --classify -v -C --group-directories-first --show-control-chars --sort=extension ; }

bash complains:

bash: /home/FreedomLover/.bashrc: line 106: syntax error near unexpected token('`

bash: /home/FreedomLover/.bashrc: line 106: 'ls () { command ls --color=always --classify -v -C --group-directories-first --show-control-chars --sort=extension' ; }

Prost.

Ed: I forgot to mention that 'alias ls' says:

ls='ls --color=auto'

I'm too much of a smooth brain to figure what I'm doing wrong here. I have the following in my bashrc: `alias ls="command ls --color=always --classify -v -C --group-directories-first --show-control-chars --sort=extension"` `cd () { command cd "$@" && ls ; }` Now, when I "cd ~/some/dir", my customized view is properly displayed. If I manually 'ls' in that dir or any other dir, my customized view is lost. Any ideas what could cause that? While I have your ear, somewhat off topic, why is it that when I write the 'ls' alias as a function, bash shits itself? When I write it like so: `ls () { command ls --color=always --classify -v -C --group-directories-first --show-control-chars --sort=extension ; }` bash complains: `bash: /home/FreedomLover/.bashrc: line 106: syntax error near unexpected token `('` `bash: /home/FreedomLover/.bashrc: line 106: 'ls () { command ls --color=always --classify -v -C --group-directories-first --show-control-chars --sort=extension' ; }` Prost. Ed: I forgot to mention that 'alias ls' says: `ls='ls --color=auto'`

(post is archived)

[–] 0 pt

I remember you from voat! We never spoke there though.

Is the shell's rc really considered a script? I know the rc can use shell script to configure it, but I thought bash understands that the rc is a config and not a .sh.

Also, doesn't the 'command' portion of the alias/function tell the shell not to see the alias/function recursively? I read that somewhere but trying to look into how 'command' works through a search engine pulls up all kinds of uselessness. 'apropos' is useless too. Can you point me to some documentation on that?

In Unix, everything is a script. That's the beauty of Unix philosophy.

.bashrc is run as

$ ./.bashrc

NOT

$ source .bashrc

NOT

$ . .bashrc

Etc...

The difference is not trivial as script kiddies may assume. For more information RTFM

$ man command

[–] 0 pt

Oh yeah, for got to mention 'man' too:

No manual entry for command

When you fully grok this, you will be enlightened.