common-aliases.plugin.zsh
2647 bytes
1# Advanced Aliases.
2# Use with caution
3#
4
5# ls, the common ones I use a lot shortened for rapid fire usage
6alias l='ls -lFh' #size,show type,human readable
7alias la='ls -lAFh' #long list,show almost all,show type,human readable
8alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable
9alias lt='ls -ltFh' #long list,sorted by date,show type,human readable
10alias ll='ls -l' #long list
11alias ldot='ls -ld .*'
12alias lS='ls -1FSsh'
13alias lart='ls -1Fcart'
14alias lrt='ls -1Fcrt'
15alias lsr='ls -lARFh' #Recursive list of files and directories
16alias lsn='ls -1' #A column contains name of files and directories
17
18alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file
19
20alias grep='grep --color'
21alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
22
23alias t='tail -f'
24
25# Command line head / tail shortcuts
26alias -g H='| head'
27alias -g T='| tail'
28alias -g G='| grep'
29alias -g L="| less"
30alias -g M="| most"
31alias -g LL="2>&1 | less"
32alias -g CA="2>&1 | cat -A"
33alias -g NE="2> /dev/null"
34alias -g NUL="> /dev/null 2>&1"
35alias -g P="2>&1| pygmentize -l pytb"
36
37alias dud='du -d 1 -h'
38(( $+commands[duf] )) || alias duf='du -sh *'
39(( $+commands[fd] )) || alias fd='find . -type d -name'
40alias ff='find . -type f -name'
41
42alias h='history'
43alias hgrep="fc -El 0 | grep"
44alias help='man'
45alias p='ps -f'
46alias sortnr='sort -n -r'
47alias unexport='unset'
48
49alias rm='rm -i'
50alias cp='cp -i'
51alias mv='mv -i'
52
53# zsh is able to auto-do some kungfoo
54# depends on the SUFFIX :)
55autoload -Uz is-at-least
56if is-at-least 4.2.0; then
57 # open browser on urls
58 if [[ -n "$BROWSER" ]]; then
59 _browser_fts=(htm html de org net com at cx nl se dk)
60 for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
61 fi
62
63 _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
64 for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
65
66 if [[ -n "$XIVIEWER" ]]; then
67 _image_fts=(jpg jpeg png gif mng tiff tif xpm)
68 for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
69 fi
70
71 _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
72 for ft in $_media_fts; do alias -s $ft=mplayer; done
73
74 #read documents
75 alias -s pdf=acroread
76 alias -s ps=gv
77 alias -s dvi=xdvi
78 alias -s chm=xchm
79 alias -s djvu=djview
80
81 #list what's inside packed file
82 alias -s zip="unzip -l"
83 alias -s rar="unrar l"
84 alias -s tar="tar tf"
85 alias -s tar.gz="echo "
86 alias -s ace="unace l"
87fi
88
89# Make zsh know about hosts already accessed by SSH
90zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'