e4082a951fe28a3da3ff63cec2b2c03fc04373c1

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(common-aliases)!: don't overshadow `fd` if installed (#9162)

BREAKING CHANGE: in `common-aliases`, the `fd` alias won't be defined if `fd` is installed (https://github.com/sharkdp/fd).

Diff

 1diff --git a/plugins/common-aliases/README.md b/plugins/common-aliases/README.md
 2index d198a29ac97e980af91fbf0950ffcd3a7e2bc75b..b6f34cb542e947973df6f1708c9b7ce1c1112741 100644
 3--- a/plugins/common-aliases/README.md
 4+++ b/plugins/common-aliases/README.md
 5@@ -40,11 +40,13 @@ plugins=(... common-aliases)
 6 
 7 | Alias | Command                                             | Description                             |
 8 |-------|-----------------------------------------------------|-----------------------------------------|
 9-| fd    | `find . -type d -name`                              | Find a directory with the given name    |
10+| fd\*  | `find . -type d -name`                              | Find a directory with the given name    |
11 | ff    | `find . -type f -name`                              | Find a file with the given name         |
12 | grep  | `grep --color`                                      | Searches for a query string             |
13 | sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}`  | Useful for searching within files       |
14 
15+\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed.
16+
17 ### Other Aliases
18 
19 | Alias     | Command             | Description                                                 |
20diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh
21index a9d4f1a3d2eb7ef090d84a4f77c247226990123a..4e5ff848f699058fd83ebe577b0eb3f910ea8d4a 100644
22--- a/plugins/common-aliases/common-aliases.plugin.zsh
23+++ b/plugins/common-aliases/common-aliases.plugin.zsh
24@@ -34,7 +34,7 @@ alias -g P="2>&1| pygmentize -l pytb"
25 
26 alias dud='du -d 1 -h'
27 alias duf='du -sh *'
28-alias fd='find . -type d -name'
29+(( $+commands[fd] )) || alias fd='find . -type d -name'
30 alias ff='find . -type f -name'
31 
32 alias h='history'