broot icon indicating copy to clipboard operation
broot copied to clipboard

Request: broot --send NONEXISTENT-SOCKET ... to yield a non-zero exit code

Open AndydeCleyre opened this issue 2 months ago • 3 comments

$ broot --send asdlfkasdjfaskldf -c ':focus /home'
error on the socket: No such file or directory (os error 2)

Currently this yields an exit code 0. I request that this be changed to any non-zero exit code, to better reflect a failure condition, when used in a scripting context.

Currently:

$ broot --send asdlfkasdjfaskldf -c ':focus /home' && echo "great success"
error on the socket: No such file or directory (os error 2)
great success

I think this is reasonable on general principle, but my very specific use case is a Zsh function which opens a broot view in an unfocused tmux "side pane." A hook is added to the shell environment so that the broot instance changes directory to match the main pane. If I later close that broot instance, I want to remove the hook.

I thought the simplest method to do so might be to have the hook function remove itself if the broot --send command ever fails:

# -- Pinned view in another tmux pane --
broot-pin () {
  emulate -L zsh
  local name=$RANDOM

  eval '
    update_pinned_broot_$name () {
      if ! { broot --send '$name' -c ":focus $PWD" 2>/dev/null } {
        add-zsh-hook -d precmd $0
        unfunction gob
      }
    }

    gob () {
      emulate -L zsh
      cd "$(broot --send '$name' --get-root)"
    }
  '

  add-zsh-hook precmd update_pinned_broot_$name
  tmux splitw -d -h -l 70 broot --listen $name
}

AndydeCleyre avatar Oct 02 '25 17:10 AndydeCleyre

can you please assign me this

Sambhram1 avatar Oct 14 '25 14:10 Sambhram1

can you please assign me this

You may propose a PR. If you have any doubt regarding the best solution, please drop by the chat. And please, have a look at https://dystroy.org/blog/contributing/

Canop avatar Oct 14 '25 14:10 Canop

#1078 tried to solve

Sambhram1 avatar Oct 14 '25 17:10 Sambhram1