Suggestion: alternative zsh `br` function
Since there's already functionality to handle different shells, I'm suggesting an alternative br launcher function to be installed for zsh. ATM, zsh shares the br shell function defined for bash:
https://github.com/Canop/broot/blob/f9fe6efebf3ce4e32d93705db8decc2019f7112f/src/shell_install/bash.rs#L41-L53
an zsh-specific alternative could be:
function br {
emulate -L zsh
(){
broot --outcmd $@ && source $1
} =() $@
}
alternate formatting:
function br {
emulate -L zsh
(){ broot --outcmd $1 ${@:2} && source $1 } =() $@
}
which is (IMO) quite a bit cleaner. instead of relying on the system's mktemp (which technically isn't standardized, although that'll never likely be an issue) and manually managing the file, this uses zsh's temp-file process substitution, and the file will be removed by zsh at the end of the anonymous function.
Any other opinion on that ?
Wow, that's short. This is what I've been using:
br () { # [<broot-opt>...]
emulate -L zsh
local cmdfile=$(mktemp)
trap "rm ${(q-)cmdfile}" EXIT INT QUIT
if { broot --outcmd "$cmdfile" $@ } {
if [[ -r $cmdfile ]] eval "$(<$cmdfile)"
} else {
return
}
}
EDIT: It's worth noting that I do experience #469
@AndydeCleyre I can reproduce that issue with the rewritten function but I don't know how to solve it yet. At least my suggestion isn't any worse than the status quo 😅
FWIW I'm now using the function in this comment.