Back to Ohmyzsh

Common Aliases Plugin

plugins/common-aliases/README.md

latest7.1 KB
Original Source

Common Aliases Plugin

This plugin creates helpful shortcut aliases for many commonly used commands.

To use it add common-aliases to the plugins array in your zshrc file:

zsh
plugins=(... common-aliases)

Aliases

ls command

AliasCommandDescription
lls -lFhList files as a long list, show size, type, human-readable
lals -lAFhList almost all files as a long list show size, type, human-readable
lrls -tRFhList files recursively sorted by date, show type, human-readable
ltls -ltFhList files as a long list sorted by date, show type, human-readable
llls -lList files as a long list
ldotls -ld .*List dot files as a long list
lSls -1FSshList files showing only size and name sorted by size
lartls -1FcartList all files sorted in reverse of create/modification time (oldest first)
lrtls -1FcrtList files sorted in reverse of create/modification time(oldest first)
lsrls -lARFhList all files and directories recursively
lsnls -1List files and directories in a single column

File handling

AliasCommandDescription
rmrm -iRemove a file
cpcp -iCopy a file
mvmv -iMove a file
zshrc${=EDITOR} ~/.zshrcQuickly access the ~/.zshrc file
duddu -d 1 -hDisplay the size of files at depth 1 in current location in human-readable form
duf*du -shDisplay the size of files in current location in human-readable form
ttail -fShorthand for tail which outputs the last part of a file

* Only if the duf command isn't installed.

find and grep

AliasCommandDescription
fd*find . -type d -nameFind a directory with the given name
fffind . -type f -nameFind a file with the given name
grepgrep --colorSearches for a query string
sgrepgrep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}Useful for searching within files

* Only if the fd command isn't installed.

Other Aliases

AliasCommandDescription
hhistoryLists all recently used commands
hgrepfc -El 0 | grepSearches for a word in the list of previously used commands
helpmanOpens up the man page for a command
pps -fDisplays currently executing processes
sortnrsort -n -rUsed to sort the lines of a text file
unexportunsetUsed to unset an environment variable

Global aliases

These aliases are expanded in any position in the command line, meaning you can use them even at the end of the command you've typed. Examples:

Quickly pipe to less:

zsh
$ ls -l /var/log L
# will run
$ ls -l /var/log | less

Silences stderr output:

zsh
$ find . -type f NE
# will run
$ find . -type f 2>/dev/null
AliasCommandDescription
H| headPipes output to head which outputs the first part of a file
T| tailPipes output to tail which outputs the last part of a file
G| grepPipes output to grep to search for some word
L| lessPipes output to less, useful for paging
M| mostPipes output to more, useful for paging
LL2>&1 | lessWrites stderr to stdout and passes it to less
CA2>&1 | cat -AWrites stderr to stdout and passes it to cat
NE2 > /dev/nullSilences stderr
NUL> /dev/null 2>&1Silences both stdout and stderr
P2>&1| pygmentize -l pytbWrites stderr to stdout and passes it to pygmentize

File extension aliases

These are special aliases that are triggered when a file name is passed as the command. For example, if the pdf file extension is aliased to acroread (a popular Linux pdf reader), when running file.pdf that file will be open with acroread.

Reading Docs

AliasCommandDescription
pdfacroreadOpens up a document using acroread
psgvOpens up a .ps file using gv
dvixdviOpens up a .dvi file using xdvi
chmxchmOpens up a .chm file using xchm
djvudjviewOpens up a .djvu file using djview

Listing files inside a packed file

AliasCommandDescription
zipunzip -lLists files inside a .zip file
rarunrar lLists files inside a .rar file
tartar tfLists files inside a .tar file
tar.gztar -ztfLists files inside a .tar.gz file
aceunace lLists files inside a .ace file

Some other features

  • Opens urls in terminal using browser specified by the variable $BROWSER
  • Opens C, C++, Tex and text files using editor specified by the variable $EDITOR
  • Opens images using image viewer specified by the variable $XIVIEWER
  • Opens videos and other media using mplayer