mathiasbynens / mathiasbynens/dotfiles

Check for `ls` flavor in `.aliases` is no longer correct

Open
#1,063 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
31.5k
Forks
8.4k
PR merge metrics
No merged PRs in 30d

Description

```bash
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
export LS_COLORS=[...]
else # macOS `ls`
colorflag="-G"
export LSCOLORS=[...]
fi
```

At some point, the macOS version of `ls` started understanding the `--color` flag (I'm on 14.4.1)

I propose this instead, but I can't test it against earlier versions of macOS:

```bash
if ls --help > /dev/null 2>&1; then
echo "GNU ls";
else
echo "MacOS ls";
fi;
```

PR to follow.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in .aliases and inspect the existing `ls --color` detection shown in the issue. Compare it with the proposed `ls --help` check and verify the behavior on the relevant GNU and macOS versions; done means the check reliably distinguishes the two `ls` flavors without breaking the color environment setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, shell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.