refactor: colourise ls based on operating system

Use different method for coloured ls on macOS & Linux.
This commit is contained in:
George Rawlinson 2021-07-08 17:16:17 +00:00
parent 63dc963b00
commit a3f9c9f462
Signed by: grawlinson
GPG Key ID: E0959FEA8B550539
1 changed files with 15 additions and 4 deletions

View File

@ -11,10 +11,21 @@ alias cp='cp -i'
alias mv='mv -i'
# ls
alias ls='ls --color=auto --human-readable --group-directories-first'
alias l='ls --classify -l'
alias la='ls --classify -la'
alias lr='ls --classify -tR'
if [[ -v OSTYPE ]]; then
if [[ "$OSTYPE" == "linux"* ]]; then
alias ls='ls --color=auto --human-readable --group-directories-first'
elif [[ "$OSTYPE" == "darwin"* ]]; then
# check for coreutils presence, otherwise we're using bsd ls
if command -v gls &> /dev/null; then
alias ls='gls --color=auto --human-readable --group-directories-first'
else
alias ls='ls -G'
fi
fi
fi
alias l='ls -l'
alias la='ls -la'
alias lr='ls -lR'
# directories
setopt AUTO_CD # prefix command with 'cd' if it cannot be executed, e.g. '..' becomes 'cd ..'