ls alias differentiation Linux, OS X, OS X with coreutils ls
parent
644e2c4e60
commit
b8393252db
|
|
@ -2,26 +2,52 @@ cite about-alias
|
||||||
about-alias 'general aliases'
|
about-alias 'general aliases'
|
||||||
|
|
||||||
# List directory contents
|
# List directory contents
|
||||||
# Source: http://tldp.org/LDP/abs/html/sample-bashrc.html
|
# Alias source: http://tldp.org/LDP/abs/html/sample-bashrc.html
|
||||||
|
|
||||||
|
local LS_COLOR_OPTION
|
||||||
|
|
||||||
|
case "$OSTYPE" in
|
||||||
|
linux*)
|
||||||
|
# Set Linux color option
|
||||||
|
LS_COLOR_OPTION="--color=auto"
|
||||||
|
;;
|
||||||
|
darwin*)
|
||||||
|
# Set BSD color optio
|
||||||
|
LS_COLOR_OPTION="-G"
|
||||||
|
#Check if coreutils version of if exists
|
||||||
|
if [[ -x "/usr/local/opt/coreutils/libexec/gnubin/ls" ]]; then
|
||||||
|
# Check if coreutils path is in $PATH
|
||||||
|
if [[ ":$PATH:" == *":/usr/local/opt/coreutils/libexec/gnubin:"* ]]; then
|
||||||
|
# Set Linux color option
|
||||||
|
LS_COLOR_OPTION="--color"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Use Linux color option as fallback
|
||||||
|
LS_COLOR_OPTION="--color=auto"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
# # Add colors for filetype and human-readable sizes by default on 'ls':
|
# # Add colors for filetype and human-readable sizes by default on 'ls':
|
||||||
alias l='ls -a --color' # Standard
|
alias l="ls -a $LS_COLOR_OPTION" # Standard
|
||||||
alias lx='ls -lXB --color' # Sort by extension.
|
alias lx="ls -lXB $LS_COLOR_OPTION" # Sort by extension.
|
||||||
alias lk='ls -lSr --color' # Sort by size, biggest last.
|
alias lk="ls -lSr $LS_COLOR_OPTION" # Sort by size, biggest last.
|
||||||
alias lt='ls -ltr --color' # Sort by date, most recent last.
|
alias lt="ls -ltr $LS_COLOR_OPTION" # Sort by date, most recent last.
|
||||||
alias lc='ls -ltcr --color' # Sort by/show change time,most recent last.
|
alias lc="ls -ltcr $LS_COLOR_OPTION" # Sort by/show change time,most recent last.
|
||||||
alias lu='ls -ltur --color' # Sort by/show access time,most recent last.
|
alias lu="ls -ltur $LS_COLOR_OPTION" # Sort by/show access time,most recent last.
|
||||||
|
|
||||||
# # The ubiquitous 'll': directories first, with alphanumeric sorting:
|
# # The ubiquitous 'll': directories first, with alphanumeric sorting:
|
||||||
alias ll="ls -lv --group-directories-first --color"
|
alias ll="ls -lv --group-directories-first $LS_COLOR_OPTION"
|
||||||
alias lm='ll |more' # Pipe through 'more'
|
alias lm="ll |more" # Pipe through "more"
|
||||||
alias lr='ll -R' # Recursive ls.
|
alias lr="ll -R" # Recursive ls.
|
||||||
alias la='ll -A' # Show hidden files.
|
alias la="ll -A" # Show hidden files.
|
||||||
|
|
||||||
alias tree='tree -C' # Nice alternative to 'recursive ls' ...
|
alias tree="tree -C" # Nice alternative to "recursive ls" ...
|
||||||
|
|
||||||
alias sl='ls'
|
alias sl="ls"
|
||||||
alias l1='ls -1 --group-directories-first --color'
|
alias l1="ls -1 --group-directories-first $LS_COLOR_OPTION"
|
||||||
|
|
||||||
|
|
||||||
alias _="sudo"
|
alias _="sudo"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue