2015-12-15 00:12:17 -05:00
|
|
|
#
|
2015-12-18 02:45:37 -05:00
|
|
|
# Utility Functions and Options
|
2015-12-15 00:12:17 -05:00
|
|
|
#
|
|
|
|
|
2015-12-15 18:49:15 -05:00
|
|
|
#
|
2016-10-28 17:17:34 -04:00
|
|
|
# Colours
|
2015-12-15 18:49:15 -05:00
|
|
|
#
|
|
|
|
|
2017-12-01 07:33:55 -05:00
|
|
|
if (( terminfo[colors] >= 8 )); then
|
|
|
|
|
2017-12-01 07:23:48 -05:00
|
|
|
# ls Colours
|
|
|
|
if (( ${+commands[dircolors]} )); then
|
|
|
|
# GNU
|
2017-12-01 07:33:55 -05:00
|
|
|
|
2018-05-24 21:39:49 -04:00
|
|
|
(( ! ${+LS_COLORS} )) && if [[ -s ${HOME}/.dir_colors ]]; then
|
|
|
|
eval "$(dircolors --sh ${HOME}/.dir_colors)"
|
|
|
|
else
|
|
|
|
export LS_COLORS='di=1;34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43'
|
|
|
|
fi
|
2018-05-24 22:09:06 -04:00
|
|
|
|
|
|
|
alias ls='ls --group-directories-first --color=auto'
|
2017-12-01 07:23:48 -05:00
|
|
|
else
|
2016-10-28 17:17:34 -04:00
|
|
|
# BSD
|
2017-12-01 07:18:40 -05:00
|
|
|
|
2018-11-19 17:13:45 -05:00
|
|
|
(( ! ${+CLICOLOR} )) && export CLICOLOR=1
|
2017-12-01 17:28:02 -05:00
|
|
|
(( ! ${+LSCOLORS} )) && export LSCOLORS='ExfxcxdxbxGxDxabagacad'
|
2017-12-01 07:18:40 -05:00
|
|
|
|
2017-12-01 07:23:48 -05:00
|
|
|
# stock OpenBSD ls does not support colors at all, but colorls does.
|
2018-11-19 17:13:45 -05:00
|
|
|
if [[ ${OSTYPE} == openbsd* && ${+commands[colorls]} -ne 0 ]]; then
|
|
|
|
alias ls='colorls'
|
2016-10-28 17:17:34 -04:00
|
|
|
fi
|
|
|
|
fi
|
2015-12-15 00:12:17 -05:00
|
|
|
|
2016-10-28 17:17:34 -04:00
|
|
|
# grep Colours
|
2017-12-01 07:23:48 -05:00
|
|
|
(( ! ${+GREP_COLOR} )) && export GREP_COLOR='37;45' #BSD
|
|
|
|
(( ! ${+GREP_COLORS} )) && export GREP_COLORS="mt=${GREP_COLOR}" #GNU
|
2016-10-28 17:17:34 -04:00
|
|
|
if [[ ${OSTYPE} == openbsd* ]]; then
|
2018-05-24 21:58:31 -04:00
|
|
|
(( ${+commands[ggrep]} )) && alias grep='ggrep --color=auto'
|
2016-04-25 01:49:05 -04:00
|
|
|
else
|
2016-10-28 17:17:34 -04:00
|
|
|
alias grep='grep --color=auto'
|
2016-04-25 01:49:05 -04:00
|
|
|
fi
|
2015-12-18 02:45:37 -05:00
|
|
|
|
2016-10-28 17:17:34 -04:00
|
|
|
# less Colours
|
|
|
|
if [[ ${PAGER} == 'less' ]]; then
|
2017-05-15 09:59:17 -04:00
|
|
|
(( ! ${+LESS_TERMCAP_mb} )) && export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking.
|
|
|
|
(( ! ${+LESS_TERMCAP_md} )) && export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold.
|
|
|
|
(( ! ${+LESS_TERMCAP_me} )) && export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
|
|
|
|
(( ! ${+LESS_TERMCAP_se} )) && export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
|
|
|
|
(( ! ${+LESS_TERMCAP_so} )) && export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode.
|
|
|
|
(( ! ${+LESS_TERMCAP_ue} )) && export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
|
|
|
|
(( ! ${+LESS_TERMCAP_us} )) && export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline.
|
2016-05-17 08:28:18 -04:00
|
|
|
fi
|
|
|
|
fi
|
2015-12-18 02:45:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# ls Aliases
|
|
|
|
#
|
|
|
|
|
2018-05-16 20:05:55 -04:00
|
|
|
alias ll='ls -lh' # long format and human-readable sizes
|
|
|
|
alias l='ll -A' # long format, all files
|
|
|
|
[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # long format, all files, use pager
|
|
|
|
alias lr='ll -R' # long format, recursive
|
|
|
|
alias lk='ll -Sr' # long format, largest file size last
|
|
|
|
alias lt='ll -tr' # long format, newest modification time last
|
|
|
|
alias lc='lt -c' # long format, newest status change (ctime) last
|
2015-12-18 02:45:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# File Downloads
|
|
|
|
#
|
|
|
|
|
2015-12-19 17:05:43 -05:00
|
|
|
# order of preference: aria2c, axel, wget, curl. This order is derrived from speed based on personal tests.
|
2015-12-18 02:45:37 -05:00
|
|
|
if (( ${+commands[aria2c]} )); then
|
2015-12-18 07:23:00 -05:00
|
|
|
alias get='aria2c --max-connection-per-server=5 --continue'
|
2015-12-18 02:45:37 -05:00
|
|
|
elif (( ${+commands[axel]} )); then
|
|
|
|
alias get='axel --num-connections=5 --alternate'
|
|
|
|
elif (( ${+commands[wget]} )); then
|
|
|
|
alias get='wget --continue --progress=bar --timestamping'
|
|
|
|
elif (( ${+commands[curl]} )); then
|
|
|
|
alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time'
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Resource Usage
|
|
|
|
#
|
|
|
|
|
2018-05-16 20:05:55 -04:00
|
|
|
alias df='df -h'
|
|
|
|
alias du='du -h'
|
2015-12-18 02:45:37 -05:00
|
|
|
|
|
|
|
|
2018-06-16 22:49:20 -04:00
|
|
|
#
|
|
|
|
# GNU only
|
|
|
|
#
|
|
|
|
|
|
|
|
if (( ${+commands[dircolors]} )); then
|
|
|
|
|
|
|
|
alias lx='ll -X' # long format, sort by extension
|
|
|
|
|
|
|
|
# Always wear a condom
|
|
|
|
alias chmod='chmod --preserve-root -v'
|
|
|
|
alias chown='chown --preserve-root -v'
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2015-12-18 02:45:37 -05:00
|
|
|
# not aliasing rm -i, but if safe-rm is available, use condom.
|
2016-01-23 19:45:55 -05:00
|
|
|
# if safe-rmdir is available, the OS is suse which has its own terrible 'safe-rm' which is not what we want
|
2016-10-28 17:17:34 -04:00
|
|
|
if (( ${+commands[safe-rm]} && ! ${+commands[safe-rmdir]} )); then
|
2016-01-23 19:45:55 -05:00
|
|
|
alias rm='safe-rm'
|
2015-12-18 02:45:37 -05:00
|
|
|
fi
|