abra zsh config 2.0
This commit is contained in:
@@ -41,30 +41,48 @@ alias ftp='noglob ftp'
|
||||
alias history='noglob history'
|
||||
alias locate='noglob locate'
|
||||
alias rake='noglob rake'
|
||||
# alias rsync='noglob rsync'
|
||||
alias rsync='noglob rsync'
|
||||
alias scp='noglob scp'
|
||||
alias sftp='noglob sftp'
|
||||
|
||||
# Define general aliases.
|
||||
alias _='sudo'
|
||||
alias b='${(z)BROWSER}'
|
||||
|
||||
alias diffu="diff --unified"
|
||||
alias e='${(z)VISUAL:-${(z)EDITOR}}'
|
||||
alias mkdir="${aliases[mkdir]:-mkdir} -p"
|
||||
alias p='${(z)PAGER}'
|
||||
alias po='popd'
|
||||
alias pu='pushd'
|
||||
alias sa='alias | grep -i'
|
||||
alias type='type -a'
|
||||
|
||||
# Safe ops. Ask the user before doing anything destructive.
|
||||
alias rmi="${aliases[rm]:-rm} -i"
|
||||
alias mvi="${aliases[mv]:-mv} -i"
|
||||
alias cpi="${aliases[cp]:-cp} -i"
|
||||
alias lni="${aliases[ln]:-ln} -i"
|
||||
if zstyle -T ':prezto:module:utility' safe-ops; then
|
||||
alias rm='rmi'
|
||||
alias mv='mvi'
|
||||
alias cp='cpi'
|
||||
alias ln='lni'
|
||||
fi
|
||||
|
||||
# ls
|
||||
if is-callable 'dircolors'; then
|
||||
# GNU Core Utilities
|
||||
alias ls='ls --group-directories-first'
|
||||
|
||||
if zstyle -t ':prezto:module:utility:ls' color; then
|
||||
if [[ -s "$HOME/.dir_colors" ]]; then
|
||||
eval "$(dircolors --sh "$HOME/.dir_colors")"
|
||||
else
|
||||
eval "$(dircolors --sh)"
|
||||
# Call dircolors to define colors if they're missing
|
||||
if [[ -z "$LS_COLORS" ]]; then
|
||||
if [[ -s "$HOME/.dir_colors" ]]; then
|
||||
eval "$(dircolors --sh "$HOME/.dir_colors")"
|
||||
else
|
||||
eval "$(dircolors --sh)"
|
||||
fi
|
||||
fi
|
||||
|
||||
alias ls="${aliases[ls]:-ls} --color=auto"
|
||||
@@ -74,11 +92,15 @@ if is-callable 'dircolors'; then
|
||||
else
|
||||
# BSD Core Utilities
|
||||
if zstyle -t ':prezto:module:utility:ls' color; then
|
||||
# Define colors for BSD ls.
|
||||
export LSCOLORS='exfxcxdxbxGxDxabagacad'
|
||||
# Define colors for BSD ls if they're not already defined
|
||||
if [[ -z "$LSCOLORS" ]]; then
|
||||
export LSCOLORS='exfxcxdxbxGxDxabagacad'
|
||||
fi
|
||||
|
||||
# Define colors for the completion system.
|
||||
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:'
|
||||
# Define colors for the completion system if they're not already defined
|
||||
if [[ -z "$LS_COLORS" ]]; then
|
||||
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:'
|
||||
fi
|
||||
|
||||
alias ls="${aliases[ls]:-ls} -G"
|
||||
else
|
||||
@@ -86,10 +108,7 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
# printf "${aliases[ls]:-ls}"
|
||||
# alias lss="${aliases[ls]:-ls}"
|
||||
# alias ls="${aliases[ls]:-ls} -A"
|
||||
alias l='ls -lAh' # Lists in one column, hidden files.
|
||||
alias l='ls -1A' # Lists in one column, hidden files.
|
||||
alias ll='ls -lh' # Lists human readable sizes.
|
||||
alias lr='ll -R' # Lists human readable sizes, recursively.
|
||||
alias la='ll -A' # Lists human readable sizes, hidden files.
|
||||
@@ -109,7 +128,7 @@ if zstyle -t ':prezto:module:utility:grep' color; then
|
||||
alias grep="${aliases[grep]:-grep} --color=auto"
|
||||
fi
|
||||
|
||||
# Mac OS X Everywhere
|
||||
# macOS Everywhere
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
alias o='open'
|
||||
elif [[ "$OSTYPE" == cygwin* ]]; then
|
||||
@@ -142,22 +161,22 @@ fi
|
||||
alias df='df -kh'
|
||||
alias du='du -kh'
|
||||
|
||||
if (( $+commands[htop] )); then
|
||||
alias top=htop
|
||||
if [[ "$OSTYPE" == (darwin*|*bsd*) ]]; then
|
||||
alias topc='top -o cpu'
|
||||
alias topm='top -o vsize'
|
||||
else
|
||||
if [[ "$OSTYPE" == (darwin*|*bsd*) ]]; then
|
||||
alias topc='top -o cpu'
|
||||
alias topm='top -o vsize'
|
||||
else
|
||||
alias topc='top -o %CPU'
|
||||
alias topm='top -o %MEM'
|
||||
fi
|
||||
alias topc='top -o %CPU'
|
||||
alias topm='top -o %MEM'
|
||||
fi
|
||||
|
||||
# Miscellaneous
|
||||
|
||||
# Serves a directory via HTTP.
|
||||
alias http-serve='python -m SimpleHTTPServer'
|
||||
if (( $+commands[python3] )); then
|
||||
alias http-serve='python3 -m http.server'
|
||||
else
|
||||
alias http-serve='python -m SimpleHTTPServer'
|
||||
fi
|
||||
|
||||
#
|
||||
# Functions
|
||||
@@ -197,3 +216,27 @@ function find-exec {
|
||||
function psu {
|
||||
ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}"
|
||||
}
|
||||
|
||||
# Enables globbing selectively on path arguments.
|
||||
# Globbing is enabled on local paths (starting in '/' and './') and disabled
|
||||
# on remote paths (containing ':' but not starting in '/' and './'). This is
|
||||
# useful for programs that have their own globbing for remote paths.
|
||||
# Currently, this is used by default for 'rsync' and 'scp'.
|
||||
# Example:
|
||||
# - Local: '*.txt', './foo:2017*.txt', '/var/*:log.txt'
|
||||
# - Remote: user@localhost:foo/
|
||||
#
|
||||
# NOTE: This function is buggy and is not used anywhere until we can make sure
|
||||
# it's fixed. See https://github.com/sorin-ionescu/prezto/issues/1443 and
|
||||
# https://github.com/sorin-ionescu/prezto/issues/1521 for more information.
|
||||
function noremoteglob {
|
||||
local -a argo
|
||||
local cmd="$1"
|
||||
for arg in ${argv:2}; do case $arg in
|
||||
( ./* ) argo+=( ${~arg} ) ;; # local relative, glob
|
||||
( /* ) argo+=( ${~arg} ) ;; # local absolute, glob
|
||||
( *:* ) argo+=( ${arg} ) ;; # remote, noglob
|
||||
( * ) argo+=( ${~arg} ) ;; # default, glob
|
||||
esac; done
|
||||
command $cmd "${(@)argo}"
|
||||
}
|
||||
|
Reference in New Issue
Block a user