Roman Danyk <17525890+RomanDanyk@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date
Message
fix(common-aliases): don't overshadow `duf` if installed (#11112)
Diff
1diff --git a/plugins/common-aliases/README.md b/plugins/common-aliases/README.md
2index 0354c7a3f6369279d85e22dc7aa070996dd0595a..1417c3056865cf82a9e6cef63afdd9bc234253cf 100644
3--- a/plugins/common-aliases/README.md
4+++ b/plugins/common-aliases/README.md
5@@ -35,9 +35,11 @@ plugins=(... common-aliases)
6 | mv | `mv -i` | Move a file |
7 | zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
8 | dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
9-| duf | `du -sh` | Display the size of files in current location in human-readable form |
10+| duf\* | `du -sh` | Display the size of files in current location in human-readable form |
11 | t | `tail -f` | Shorthand for tail which outputs the last part of a file |
1213+\* Only if the [`duf`](https://github.com/muesli/duf) command isn't installed.
14+
15 ### find and grep
1617 | Alias | Command | Description |
18@@ -66,12 +68,15 @@ These aliases are expanded in any position in the command line, meaning you can
19 end of the command you've typed. Examples:
2021 Quickly pipe to less:
22+
23 ```zsh
24 $ ls -l /var/log L
25 # will run
26 $ ls -l /var/log | less
27 ```
28+
29 Silences stderr output:
30+
31 ```zsh
32 $ find . -type f NE
33 # will run
34diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
35index 8b58b631077b6f3cf4da1430aefb3c71e97bf3f8..3139b821aa128fe1c51b425018401b4a34f15f9e 100644
36--- a/plugins/common-aliases/common-aliases.plugin.zsh
37+++ b/plugins/common-aliases/common-aliases.plugin.zsh
38@@ -35,7 +35,7 @@ alias -g NUL="> /dev/null 2>&1"
39 alias -g P="2>&1| pygmentize -l pytb"
4041 alias dud='du -d 1 -h'
42-alias duf='du -sh *'
43+(( $+commands[duf] )) || alias duf='du -sh *'
44 (( $+commands[fd] )) || alias fd='find . -type d -name'
45 alias ff='find . -type f -name'
46