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

View file

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