1

I am trying to customize ls command adding arguments to $LS_OPTIONS

The ls alias and LS_OPTIONS are defined in the default config file:

export LS_OPTIONS='--color=auto'
...
alias ls='ls $LS_OPTIONS'

I redefined $LS_OPTIONS at the end of .zshrc file:

export LS_OPTIONS='--color=auto --group-directories-first'

after sourcing .zshrc, I type ls and get:

ls: unrecognized option '--group-directories-first --color=auto'
Try 'ls --help' for more information.

clearly the whole variable is passed as a single argument, which is wrong. I tried:

unalias ls 
ls $LS_OPTIONS

and got the same error.

In bash it works correctly:

bash
unalias ls
ls $LS_OPTIONS
#-> list of files

Please can help?

1

1 Answer 1

2

zsh wants you to use array.

LS_OPTIONS=(--color=auto --group-directories-first)
ls $LS_OPTIONS

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .