How do I use LS_OPTIONS?

hi, so yeah, export LS_OPTIONS='--group-directories-first --color=auto' don’t do what I expected it to do

how do I use it? thank you in advance for your replies.

I would think space in the beginning would matter

You can experiment with the setting without having to fiddle with export

 $ LS_OPTIONS=' --group-directories-first --color=auto'
 $ ls $LS_OPTIONS ~/

Played around with it - a globl LS_OPTIONS environment variable appears to be ignored on Manjaro, it could be something that is specific to another distribution e.g. Ubuntu - but I don’t really know.

Looking at the ls(1) — Arch manual pages there is no mention of LS_OPTIONS only LS_COLORS

1 Like

If you have multiple parameters you must define it as bash array eg.:

LS_OPTIONS=("--color=auto" "--group-directories-first")
2 Likes

Use an array like @tomek said.

However the export will only work until you logout or reboot. If you want it to be permanent, you should to add it to your ~/.zshrc

echo 'export LS_OPTIONS=("--color=auto" "--group-directories-first")' >> ~/.zshrc

@linux-aarhus

As it turns out, this (perhaps) little known feature is part of Manjaro’s zsh config. I found it in /usr/share/zsh/manjaro-zsh-config (last 4 lines).

# File and Dir colors for ls and other outputs
export LS_OPTIONS='--color=auto'
eval "$(dircolors -b)"
alias ls='ls $LS_OPTIONS'

Ahh - I see - searched in manuals - but since I don’t use zsh - it went completely over my head :slight_smile: thank you.

1 Like

I do use zsh, but I have a custom config so it didn’t work for me either.

The fact they got an error made me think it might be in the default config.