From f60d25e47c322530181b36276182f4099ebd9ef7 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 5 Feb 2025 16:32:07 +0100 Subject: [PATCH] zsh:bfs(): Don't print non-empty dirs by default I sometimes use find (nowadays bfs) to get an overview of a directory. In that case I want the output to be as short as possible. --- .config/zsh/zshrc.d/40-functions.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 0986edf..7f154e7 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -744,3 +744,17 @@ rmdir() { command rmdir "$@" fi } + +# bfs wrapper with condensed output by default (i.e. no directories except if +# they're empty) +(( ! $+commands[bfs] )) || bfs() { + emulate -L zsh + + # Check if arguments were passed that start with a dash + if (( $# && ${@[(I)-*]} )); then + command bfs "$@" + else + # Only print files and empty directories + command bfs "$@" -type f -o -type d -empty + fi +}