Normal Aliases

LS variants

alias ls='ls -CFb'
alias la='ls -LaFb'
alias ll='ls -lFb'
alias isols='TIME_STYLE="+%Y%m%d %H:%M:%S" ll'


alias cvscat='cvs -q update -p'
alias j='jobs -lpd'
alias hr=$'echo ${(l:$COLUMNS::\u2501:)}'
alias myip='curl'
alias lvared="IFS=\$'\n' vared"

Cleaning up

This is useful, if you want to remove systemwide aliases from your config:

unhash -am '*'

Precommand Modifiers

nocorrect and noglob are useful for some commands:

for com in alias expr find iptables mattrib mcopy mdir mdel which;
  alias $com="noglob $com"
for com in cp mkdir mv folder refile; alias $com="nocorrect $com"

Use alias expansion after precommands

for com in command builtin time nice - nocorrect exec rusage noglob eval nohup;
  alias -- $com="$com "

Common Aliases

fast directory change

alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
# upgrade shortcut for debian users
[ -r /etc/debian_version ] && [ -x `which sudo` ] && alias upgrade='sudo apt-get update && sudo apt-get -u upgrade'

# vared variant which splits arrays onto separate lines
alias lvared="IFS=\$'\n' vared"

# After some commands, it is useful to avoid filename generation:
for com in alias expr find mattrib mcopy mdir mdel which ; do alias $com="noglob $com" ; done

# editing the last (newest file) in a directory
## (. matches plain files, ^D disables the GLOB_DOTS option
## (no dot-files are included), om sorts the files by modification date,
## [1] selects the first of them.)
alias vil='vi *(.om[1]^D)'

# Very often I want to see a bunch of history entries instead of simply searching back:
alias hg='fc -l 0|grep' 

# Remove trash
alias rmold='rm -vf .*~ *~ \#*\#' # verbose, ignore errors and don't ask.
alias rmtex='rm -vf .*~ *~ *log *.nav *.snm *.toc  *.cp *.fn *.tp *.vr *.pg *.ky \#* *blg *ilg *.dvi *.aux;\
             rm -vfr ./auto/'
alias rmps='rm -vf *.ps'


Checking for options before setting them. Some Linux dists (Debian) will ship grep without support for perl regexp, so it's good to check it before setting it:

if [[ 0 -eq `echo $SHELL|grep --perl-regexp sh &>/dev/null; echo $?` ]]
    then GRP='--perl-regexp'
if [[ 1 -eq `grep --help|grep --count color` ]]
    then GRP='--color=auto '$GRP ;fi
alias grep='grep --ignore-case '$GRP
unset GRP
examples/aliasnormal.txt · Last modified: 2015/03/24 17:25 by remove-spam-mckael