[bash] improve ls aliases

When the GNU version of `ls` is not installed (e.g. on a new Mac), the
previous alias causes problems because the --group-directories-first
option is not supported and makes `ls` fail. This commit fixes that by
checking which version is installed and creating the alias accordingly.
This commit is contained in:
Fernando Schauenburg 2018-03-04 18:19:01 +01:00
parent 36ce14439b
commit 3e64d54317

11
bashrc
View file

@ -24,13 +24,18 @@ do
done
# Useful aliases
if ls --group-directories-first >/dev/null 2>&1
then
ls_dir_group="--group-directories-first" # GNU version
else
ls_dir_group="" # BSD version, doesn't support directory grouping
fi
alias g="git"
alias ls="ls -F --color=auto --group-directories-first"
alias ls="ls -hF --color=auto ${ls_dir_group}"
alias la="ls -a"
alias ll="ls -l"
alias lla="ls -la"
alias llh="ls -lh"
alias llha="ls -lha"
alias grep="grep --color=auto";
alias egrep="egrep --color=auto";
alias fgrep="fgrep --color=auto";