Broot: A new way to see and navigate directory trees

A new way to see and navigate directory trees : https://dystroy.org/broot

I want to make broot open files on enter without closing, and if I can make that work, it would probably replace nnn, just right now still having issues making it play nice on os-x.

broot worth it.
dcd() { br --only-folders --cmd "$1 :cd" || exit 1; }
dcd : Deep fuzzy cd
Thanks for the tip Robert.

@duncan thank you so much for the link, now I can make broot do my bidding!

Anyone (@duncan) find a way to keep broot open after opening a file with ?

In my case if I hit enter it opens without closing broot. However, if I press alt-enter, then it is closed afterwards. I use this to open files because I have the app connect-kak as default for text files.

However, if you are using the verb e to open files, you need to add the line leave_broot = false below the verb edit (e) to the config file .config/broot/conf.toml.

Check

https://dystroy.org/broot/documentation/configuration/

1 Like

broot/conf.toml

[[verbs]]
invocation = "glow"
shortcut = "md"
execution = "glow {file} -p"
leave_broot = false

Great stuff thanks. Also works well with viewing *.properties files.


And with a cherry on top :birthday:.

[[verbs]]
invocation = "taskell"
shortcut = "task"
execution = "taskell"
leave_broot = false

Just to cover up my random emoji thought of the day. :sunglasses:

cdd() { cd "$(fd --max-depth 5 --type d | fzy -l 25)" || exit 1; }
maww() { kak "$(fd --max-depth 5 --type f --extension $1 | fzy -l 55)" || exit 1; }

fd & fzy.

w3m is a text-based web browser as well as a pager like ‘more’ or ‘less’.

[[verbs]]
invocation = "w3m"
shortcut = "web"
execution = "w3m {file}"
leave_broot = false

Great tool for viewing api / coverage / test docs with links and just plain in the terminal www surfing.

[[verbs]]
invocation = "bat"
shortcut = "bat"
execution = "bat {file}"
leave_broot = false

bat A cat(1) clone with syntax highlighting and Git integration.
@alexherbo2 thank you for this one. Great for viewing code files as a pager.
export BAT_PAGER="less -RF"
note: bat will exit in broot if file length < buffer length, so glow to the rescue.

2 Likes

See also: Broot

This is what the creator of broot suggested to me: Tips & tricks - Broot. Grep for “select.toml”.

I open it in a new tmux window, à la suspend-and-resume.

I never got suspend and resume working properly, I need to poke around that…

I basically got rid of all that smart automation stuff relying on the window manager and just opened a new tmux window with tmux new-window instead. Not tool independent, unfortunately, but easily adjusted for kitty or i3 workflows.

Edit:

This is my suspend-and-resume alternative (ignore the ${pkgs.tmux}/bin/ nix escapes):

def launch-tmux-workflow \
    -params 1..2 \
    -docstring 'launch-tmux-workflow <cli command> [<kak command after resume>]: Runs specified cli command in new tmux window.  Upon exit of command the optional kak command is executed.' \
    %{ evaluate-commands %sh{

    cli_cmd="$1"
    post_resume_cmd="$2"

    ${pkgs.tmux}/bin/tmux new-window "$cli_cmd; ${pkgs.tmux}/bin/tmux wait-for -S kak-launch-tmux-workflow-$kak_client_pid" > /dev/null 2>&1
    ${pkgs.tmux}/bin/tmux wait-for kak-launch-tmux-workflow-$kak_client_pid > /dev/null 2>&1
    echo $post_resume_cmd
}}

And this is how I use it with broot with for-each-line from https://github.com/mawww/kakoune/wiki/Integrating-Other-CLI-apps:

def toggle-broot %{
    launch-tmux-workflow \
        "${pkgs.broot}/bin/broot --conf=$HOME/.config/broot/select.toml > /tmp/broot-files-%val{client_pid}" \
        "for-each-line edit /tmp/broot-files-%val{client_pid}"
}
map global user b ': toggle-broot<ret>' -docstring 'select files in broot'