Fixed vim and zsh
This commit is contained in:
48
zsh/modules/utility/README.md
Normal file
48
zsh/modules/utility/README.md
Normal file
@ -0,0 +1,48 @@
|
||||
Utility
|
||||
=======
|
||||
|
||||
Utility aliases and functions.
|
||||
|
||||
Adds colour to `ls`, `grep` and `less`.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### ls
|
||||
|
||||
| alias | command | description |
|
||||
| ----- | ------- | ----------- |
|
||||
| `ls` | `ls --group-directories-first --color=auto` | directories first, use color (applies to all ls aliases) |
|
||||
| `l` | `ls -lAh` | all files, human-readable sizes |
|
||||
| `lm` | `l | ${PAGER}` | all files, human-readable sizes, use pager |
|
||||
| `ll` | `ls -lh` | human-readable sizes |
|
||||
| `lr` | `ll -R` | human-readable sizes, recursive |
|
||||
| `lx` | `ll -XB` | human-readable sizes, sort by extension (GNU only) |
|
||||
| `lk` | `ll -Sr` | human-readable sizes, largest last |
|
||||
| `lt` | `ll -tr` | human-readable sizes, most recent last |
|
||||
| `lc` | `lt -c` | human-readable sizes, most recent last, change time |
|
||||
|
||||
### File Downloads
|
||||
|
||||
Aliases `get` to ( `aria2c` || `axel` || `wget` || `curl` ).
|
||||
|
||||
### Resource Usage
|
||||
|
||||
| alias | command |
|
||||
| ----- | ------- |
|
||||
| `df` | `df -kh` |
|
||||
| `du` | `du -kh` |
|
||||
|
||||
### Condoms
|
||||
|
||||
| alias | command |
|
||||
| ----- | ------- |
|
||||
| `chmod` | `chmod --preserve-root -v` |
|
||||
| `chown` | `chown --preserve-root -v` |
|
||||
| `rm` | if available, `safe-rm` |
|
||||
|
||||
### Misc
|
||||
|
||||
| alias | description |
|
||||
| ----- | ----------- |
|
||||
| `mkcd` | mkdir and cd |
|
122
zsh/modules/utility/init.zsh
Normal file
122
zsh/modules/utility/init.zsh
Normal file
@ -0,0 +1,122 @@
|
||||
#
|
||||
# Utility Functions and Options
|
||||
#
|
||||
|
||||
#
|
||||
# Colours
|
||||
#
|
||||
|
||||
if [[ ! -z ${terminfo[colors]} ]] && (( ${terminfo[colors]} >= 8 )); then
|
||||
# ls Colors
|
||||
if (( ${+commands[dircolors]} )); then
|
||||
# GNU
|
||||
if [[ -s ${HOME}/.dir_colors ]]; then
|
||||
eval "$(dircolors --sh ${HOME}/.dir_colors)"
|
||||
else
|
||||
eval "$(dircolors --sh)"
|
||||
fi
|
||||
|
||||
alias ls='ls --group-directories-first --color=auto'
|
||||
|
||||
else
|
||||
# BSD
|
||||
|
||||
# colours for ls and completion
|
||||
export LSCOLORS='exfxcxdxbxGxDxabagacad'
|
||||
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=36;01:cd=33;01:su=31;40;07:sg=36;40;07:tw=32;40;07:ow=33;40;07:'
|
||||
|
||||
# stock OpenBSD ls does not support colors at all, but colorls does.
|
||||
if [[ $OSTYPE == openbsd* ]]; then
|
||||
if (( ${+commands[colorls]} )); then
|
||||
alias ls='colorls -G'
|
||||
fi
|
||||
else
|
||||
alias ls='ls -G'
|
||||
fi
|
||||
fi
|
||||
|
||||
# grep Colours
|
||||
export GREP_COLOR='37;45' #BSD
|
||||
export GREP_COLORS="mt=${GREP_COLOR}" #GNU
|
||||
if [[ ${OSTYPE} == openbsd* ]]; then
|
||||
if (( ${+commands[ggrep]} )); then
|
||||
alias grep='ggrep --color=auto'
|
||||
fi
|
||||
else
|
||||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
# less Colours
|
||||
if [[ ${PAGER} == 'less' ]]; then
|
||||
export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking.
|
||||
export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold.
|
||||
export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
|
||||
export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
|
||||
export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode.
|
||||
export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
|
||||
export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline.
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# ls Aliases
|
||||
#
|
||||
|
||||
alias l='ls -lAh' # all files, human-readable sizes
|
||||
[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # all files, human-readable sizes, use pager
|
||||
alias ll='ls -lh' # human-readable sizes
|
||||
alias lr='ll -R' # human-readable sizes, recursive
|
||||
alias lx='ll -XB' # human-readable sizes, sort by extension (GNU only)
|
||||
alias lk='ll -Sr' # human-readable sizes, largest last
|
||||
alias lt='ll -tr' # human-readable sizes, most recent last
|
||||
alias lc='lt -c' # human-readable sizes, most recent last, change time
|
||||
|
||||
|
||||
#
|
||||
# File Downloads
|
||||
#
|
||||
|
||||
# order of preference: aria2c, axel, wget, curl. This order is derrived from speed based on personal tests.
|
||||
if (( ${+commands[aria2c]} )); then
|
||||
alias get='aria2c --max-connection-per-server=5 --continue'
|
||||
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
|
||||
#
|
||||
|
||||
alias df='df -kh'
|
||||
alias du='du -kh'
|
||||
|
||||
|
||||
#
|
||||
# Always wear a condom
|
||||
#
|
||||
|
||||
if [[ ${OSTYPE} == linux* ]]; then
|
||||
alias chmod='chmod --preserve-root -v'
|
||||
alias chown='chown --preserve-root -v'
|
||||
fi
|
||||
|
||||
# not aliasing rm -i, but if safe-rm is available, use condom.
|
||||
# if safe-rmdir is available, the OS is suse which has its own terrible 'safe-rm' which is not what we want
|
||||
if (( ${+commands[safe-rm]} && ! ${+commands[safe-rmdir]} )); then
|
||||
alias rm='safe-rm'
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Misc
|
||||
#
|
||||
|
||||
mkcd() {
|
||||
[[ -n ${1} ]] && mkdir -p ${1} && builtin cd ${1}
|
||||
}
|
BIN
zsh/modules/utility/init.zsh.zwc
Normal file
BIN
zsh/modules/utility/init.zsh.zwc
Normal file
Binary file not shown.
Reference in New Issue
Block a user