From cd37d19ddaf9cc5acbf443f93f88ca355f74090d Mon Sep 17 00:00:00 2001 From: Florian Boulay Date: Sat, 8 Oct 2016 08:26:10 +0200 Subject: Add m4a format in the common aliases plugin (#5502) The m4a file format can be opened in the command line with mplayer --- plugins/common-aliases/common-aliases.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index c7aafd8b8..128db6e5f 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -63,7 +63,7 @@ if is-at-least 4.2.0; then _image_fts=(jpg jpeg png gif mng tiff tif xpm) for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done - _media_fts=(ape avi flv mkv mov mp3 mpeg mpg ogg ogm rm wav webm) + _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) for ft in $_media_fts ; do alias -s $ft=mplayer ; done #read documents -- cgit v1.2.3-70-g09d2 From d47a7221924b4fa0b1859913d505f50a6c276da1 Mon Sep 17 00:00:00 2001 From: Marco De Bortoli Date: Tue, 1 Nov 2016 15:49:50 +1100 Subject: PHP suffix alias should be removed PHP can be executed as CLI script but due to the automated attempt to add browser support to that extension such ability is prevented in certain circumstances. --- plugins/common-aliases/common-aliases.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 128db6e5f..0908c8a38 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -54,7 +54,7 @@ alias mv='mv -i' # depends on the SUFFIX :) if is-at-least 4.2.0; then # open browser on urls - _browser_fts=(htm html de org net com at cx nl se dk dk php) + _browser_fts=(htm html de org net com at cx nl se dk dk) for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) -- cgit v1.2.3-70-g09d2 From fc4e0cd7ba47bc87fe707f2bac8edb3461cfdd36 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 2 Nov 2016 11:02:58 +0100 Subject: common-aliases: check if $BROWSER is defined on browser aliases --- plugins/common-aliases/common-aliases.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 0908c8a38..e888ff076 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -54,8 +54,10 @@ alias mv='mv -i' # depends on the SUFFIX :) if is-at-least 4.2.0; then # open browser on urls - _browser_fts=(htm html de org net com at cx nl se dk dk) - for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done + if [[ -n "$BROWSER" ]]; then + _browser_fts=(htm html de org net com at cx nl se dk dk) + for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done + fi _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done -- cgit v1.2.3-70-g09d2 From cb26c2f6145ab36a2bb3b3d5392959cf741f2608 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 2 Nov 2016 11:03:47 +0100 Subject: common-aliases: minor style fixes --- plugins/common-aliases/common-aliases.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index e888ff076..d47b20e40 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -56,17 +56,17 @@ if is-at-least 4.2.0; then # open browser on urls if [[ -n "$BROWSER" ]]; then _browser_fts=(htm html de org net com at cx nl se dk dk) - for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done + for ft in $_browser_fts; do alias -s $ft=$BROWSER; done fi _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) - for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done + for ft in $_editor_fts; do alias -s $ft=$EDITOR; done _image_fts=(jpg jpeg png gif mng tiff tif xpm) - for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done + for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) - for ft in $_media_fts ; do alias -s $ft=mplayer ; done + for ft in $_media_fts; do alias -s $ft=mplayer; done #read documents alias -s pdf=acroread -- cgit v1.2.3-70-g09d2 From 0f62b7a8d8708910e75fedb9d7b8e3d8559a34da Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 2 Nov 2016 11:17:58 +0100 Subject: common-aliases: check if `$XIVIEWER` is defined and minor fixes --- plugins/common-aliases/common-aliases.plugin.zsh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index d47b20e40..742798f27 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -55,15 +55,17 @@ alias mv='mv -i' if is-at-least 4.2.0; then # open browser on urls if [[ -n "$BROWSER" ]]; then - _browser_fts=(htm html de org net com at cx nl se dk dk) + _browser_fts=(htm html de org net com at cx nl se dk) for ft in $_browser_fts; do alias -s $ft=$BROWSER; done fi _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) for ft in $_editor_fts; do alias -s $ft=$EDITOR; done - _image_fts=(jpg jpeg png gif mng tiff tif xpm) - for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done + if [[ -n "$XIVIEWER" ]]; then + _image_fts=(jpg jpeg png gif mng tiff tif xpm) + for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done + fi _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) for ft in $_media_fts; do alias -s $ft=mplayer; done @@ -85,4 +87,3 @@ fi # Make zsh know about hosts already accessed by SSH zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' - -- cgit v1.2.3-70-g09d2 From 0d80e9b4ee4925da24f5c2ef9082f6660d983113 Mon Sep 17 00:00:00 2001 From: Elton Chen-Yu Ho Date: Tue, 19 Jun 2018 04:12:07 +0800 Subject: Fix zshrc alias when $EDITOR uses parameters (#6146) According to #5003 if one exports EDITOR with parameters, say: `export EDITOR='subl -w'` running command: `zshrc` will result in: `zsh: command not found: subl -w` This can be fixed by updating common-aliases.plugin.zsh line 16 with: `alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file` Fixes #5003 --- plugins/common-aliases/common-aliases.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 742798f27..6a7daf845 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -13,7 +13,7 @@ alias lS='ls -1FSsh' alias lart='ls -1Fcart' alias lrt='ls -1Fcrt' -alias zshrc='$EDITOR ~/.zshrc' # Quick access to the ~/.zshrc file +alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file alias grep='grep --color' alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' -- cgit v1.2.3-70-g09d2 From 6af58f492f8c5219e27f74cf6378e92834d1b3e5 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 18 Jun 2018 22:47:51 +0200 Subject: common-aliases: delete unexistant command `display_info` doesn't exist in any known platform Fixes #5208 --- plugins/common-aliases/common-aliases.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 6a7daf845..785a09c63 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -44,8 +44,6 @@ alias p='ps -f' alias sortnr='sort -n -r' alias unexport='unset' -alias whereami=display_info - alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' -- cgit v1.2.3-70-g09d2 From 9817e1e7ff62494abf9d7c78870e92908567e8f4 Mon Sep 17 00:00:00 2001 From: Gopal9816 Date: Sat, 27 Jul 2019 17:39:00 +0530 Subject: common-aliases: add README (#8039) --- plugins/common-aliases/README.md | 121 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 plugins/common-aliases/README.md (limited to 'plugins/common-aliases') diff --git a/plugins/common-aliases/README.md b/plugins/common-aliases/README.md new file mode 100644 index 000000000..d198a29ac --- /dev/null +++ b/plugins/common-aliases/README.md @@ -0,0 +1,121 @@ +# 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 + +| Alias | Command | Description | +|-------|---------------|--------------------------------------------------------------------------------| +| l | `ls -lFh` | List files as a long list, show size, type, human-readable | +| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable | +| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable | +| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable | +| ll | `ls -l` | List files as a long list | +| ldot | `ls -ld .*` | List dot files as a long list | +| lS | `ls -1FSsh` | List files showing only size and name sorted by size | +| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) | +| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) | + +### File handling + +| Alias | Command | Description | +|-------|-----------------------|------------------------------------------------------------------------------------| +| rm | `rm -i` | Remove a file | +| cp | `cp -i` | Copy a file | +| mv | `mv -i` | Move a file | +| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file | +| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form | +| duf | `du -sh` | Display the size of files in current location in human-readable form | +| t | `tail -f` | Shorthand for tail which outputs the last part of a file | + +### find and grep + +| Alias | Command | Description | +|-------|-----------------------------------------------------|-----------------------------------------| +| fd | `find . -type d -name` | Find a directory with the given name | +| ff | `find . -type f -name` | Find a file with the given name | +| grep | `grep --color` | Searches for a query string | +| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files | + +### Other Aliases + +| Alias | Command | Description | +|-----------|---------------------|-------------------------------------------------------------| +| h | `history` | Lists all recently used commands | +| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands | +| help | `man` | Opens up the man page for a command | +| p | `ps -f` | Displays currently executing processes | +| sortnr | `sort -n -r` | Used to sort the lines of a text file | +| unexport | `unset` | Used 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 +``` + +| Alias | Command | Description | +|-------|-----------------------------|-------------------------------------------------------------| +| H | `\| head` | Pipes output to head which outputs the first part of a file | +| T | `\| tail` | Pipes output to tail which outputs the last part of a file | +| G | `\| grep` | Pipes output to grep to search for some word | +| L | `\| less` | Pipes output to less, useful for paging | +| M | `\| most` | Pipes output to more, useful for paging | +| LL | `2>&1 \| less` | Writes stderr to stdout and passes it to less | +| CA | `2>&1 \| cat -A` | Writes stderr to stdout and passes it to cat | +| NE | `2 > /dev/null` | Silences stderr | +| NUL | `> /dev/null 2>&1` | Silences both stdout and stderr | +| P | `2>&1\| pygmentize -l pytb` | Writes 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 + +| Alias | Command | Description | +|-------|-------------|-------------------------------------| +| pdf | `acroread` | Opens up a document using acroread | +| ps | `gv` | Opens up a .ps file using gv | +| dvi | `xdvi` | Opens up a .dvi file using xdvi | +| chm | `xchm` | Opens up a .chm file using xchm | +| djvu | `djview` | Opens up a .djvu file using djview | + +### Listing files inside a packed file + +| Alias | Command | Description | +|---------|-------------|-------------------------------------| +| zip | `unzip -l` | Lists files inside a .zip file | +| rar | `unrar l` | Lists files inside a .rar file | +| tar | `tar tf` | Lists files inside a .tar file | +| tar.gz | `echo` | Lists files inside a .tar.gz file | +| ace | `unace l` | Lists 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 -- cgit v1.2.3-70-g09d2