From ed2b9e760c6db5ca095c72fa83acff07a8bbd95e Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Wed, 5 Feb 2025 16:44:38 +0100 Subject: [PATCH] zsh:bfs(): Make sure that std{out,err} are ttys When piping its output, I want the normal behaviour. Also swap the if and else branches for better readability. --- .config/zsh/zshrc.d/40-functions.zsh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 7f154e7..e32705d 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -750,11 +750,12 @@ rmdir() { (( ! $+commands[bfs] )) || bfs() { emulate -L zsh - # Check if arguments were passed that start with a dash - if (( $# && ${@[(I)-*]} )); then - command bfs "$@" - else + # Make sure that std{out,err} are associated with a tty and that no + # arguments were passed that start with a dash + if [[ -t 1 && -t 2 ]] && (( ! $# || ! ${@[(I)-*]} )); then # Only print files and empty directories command bfs "$@" -type f -o -type d -empty + else + command bfs "$@" fi }