mathiasbynens / mathiasbynens/dotfiles
Check for `ls` flavor in `.aliases` is no longer correct
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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