From f30daa76efa3e35f269c5a5a993c82e94799a074 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Fri, 7 Aug 2020 14:35:58 +0000 Subject: [PATCH 1/3] aliases: Don't overshadow fd --- plugins/common-aliases/common-aliases.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 023b1a51e..8f3045db4 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -34,7 +34,9 @@ alias -g P="2>&1| pygmentize -l pytb" alias dud='du -d 1 -h' alias duf='du -sh *' -alias fd='find . -type d -name' +if ! which fd >/dev/null 2>%1; then + alias fd='find . -type d -name' +fi alias ff='find . -type f -name' alias h='history' From fbee1ff8bda5a4491a4d003023f27daf04e09f4a Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Thu, 10 Dec 2020 01:50:01 +0530 Subject: [PATCH 2/3] fd: Rework command to be more idiomatic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/common-aliases/common-aliases.plugin.zsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh index 8f3045db4..231037a92 100644 --- a/plugins/common-aliases/common-aliases.plugin.zsh +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -34,9 +34,7 @@ alias -g P="2>&1| pygmentize -l pytb" alias dud='du -d 1 -h' alias duf='du -sh *' -if ! which fd >/dev/null 2>%1; then - alias fd='find . -type d -name' -fi +(( $+commands[fd] )) || alias fd='find . -type d -name' alias ff='find . -type f -name' alias h='history' From 5feb2b67428546c7e50b510f9d644ce24e1d5c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Wed, 9 Dec 2020 23:11:31 +0100 Subject: [PATCH 3/3] Document fd alias change in README --- plugins/common-aliases/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/common-aliases/README.md b/plugins/common-aliases/README.md index d198a29ac..b6f34cb54 100644 --- a/plugins/common-aliases/README.md +++ b/plugins/common-aliases/README.md @@ -40,11 +40,13 @@ plugins=(... common-aliases) | Alias | Command | Description | |-------|-----------------------------------------------------|-----------------------------------------| -| fd | `find . -type d -name` | Find a directory with the given name | +| 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 | +\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed. + ### Other Aliases | Alias | Command | Description |