Add bash aliases to force ls
colored output
This is useful when piping the output of `ls` into `less` or another pager. However, I added new aliases because making the default ones force color would cause problems when piping into other commands or directly to files, since the terminal escape characters would then clobber the data.
This commit is contained in:
parent
e5e03369c1
commit
2a6a32e92c
1 changed files with 13 additions and 4 deletions
|
@ -81,16 +81,25 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
bashrc_customize_aliases() {
|
bashrc_customize_aliases() {
|
||||||
# Group directories first if supported by the available `ls` command.
|
# Make `ls` group directories first if supported.
|
||||||
local ls_dir_group=""
|
|
||||||
if ls --group-directories-first >/dev/null 2>&1; then
|
if ls --group-directories-first >/dev/null 2>&1; then
|
||||||
ls_dir_group="--group-directories-first"
|
alias ls="ls -hF --group-directories-first --color=auto" # GNU
|
||||||
|
else
|
||||||
|
alias ls="ls -hF -G" # BSD
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Force `ls` to use color output (e.g. for piping into `less`).
|
||||||
|
if ls --color=auto >/dev/null 2>&1; then
|
||||||
|
alias lsc="ls --color=always" # GNU
|
||||||
|
else
|
||||||
|
alias lsc="/usr/bin/env CLICOLOR_FORCE=1 ls" # BSD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
alias ls="ls -hF --color=auto ${ls_dir_group}"
|
|
||||||
alias la="ls -a"
|
alias la="ls -a"
|
||||||
alias ll="ls -l"
|
alias ll="ls -l"
|
||||||
|
alias llc="lsc -l"
|
||||||
alias lla="ls -la"
|
alias lla="ls -la"
|
||||||
|
alias llac="lsc -la"
|
||||||
alias grep="grep --color=auto";
|
alias grep="grep --color=auto";
|
||||||
alias egrep="egrep --color=auto";
|
alias egrep="egrep --color=auto";
|
||||||
alias fgrep="fgrep --color=auto";
|
alias fgrep="fgrep --color=auto";
|
||||||
|
|
Loading…
Add table
Reference in a new issue