zsh:funcs: Add find() wrapper analog to bfs()

Only difference is that it places a trailing slash behind (empty)
directory names to differentiate them better. bfs does this already.

TODO: Bring these together into one function that checks $0
This commit is contained in:
2025-02-05 16:48:10 +01:00
parent ed2b9e760c
commit d57ee922c9

View File

@@ -759,3 +759,20 @@ rmdir() {
command bfs "$@"
fi
}
# TODO: bring together with bfs
# find wrapper with condensed output by default (i.e. no directories except if
# they're empty)
(( ! $+commands[find] )) || find() {
emulate -L zsh
# 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 (and mark these with a
# trailing slash)
command find "$@" -type f -print -o -type d -empty -printf "%p/\n"
else
command find "$@"
fi
}