canop / broot Goto Github PK
View Code? Open in Web Editor NEWA new way to see and navigate directory trees : https://dystroy.org/broot
License: MIT License
A new way to see and navigate directory trees : https://dystroy.org/broot
License: MIT License
I noticed issues when using this to cd into a directory which is under folders or hard drive names having spaces in them as the command being executed splits up the directory into two parameters and the cd says that the cd has too many arguments.
I fixed my issue with the following changes into the bash launder script (under ~/.config/broot/launcher/bash/br) with the following disclaimer: I just didn't know anything about bash scripting before hand so I just have to use answers I found on google and try to patch whatever I can and it now apparently works which shows in how inelegant it looks, and I really don't know if this was really an issue, I just found it doesn't cd properly with a path having spaces in them, sorry if this was already fixed and I was just using it wrong (also first time trying to use a terminal file manager)
# This script was automatically generated by the broot function
# More information can be found in https://github.com/Canop/broot/blob/master/documentation.md
# This function starts broot and executes the command
# it produces, if any.
# It's needed because some shell commands, like `cd`,
# have no useful effect if executed in a subshell.
function br {
f=$(mktemp)
(
set +e
broot --outcmd "$f" "$@"
code=$?
if [ "$code" != 0 ]; then
rm -f "$f"
exit "$code"
fi
)
code=$?
if [ "$code" != 0 ]; then
return "$code"
fi
d=$(cat "$f")
#hacky fix
OIFS=$IFS
IFS=' '
read -a sPlit <<< "${d}"
IFS="$OIFS"
if [ ${#sPlit[@]} > 2 ]; then
d="${sPlit[0]} "
d+='"'
d+="${sPlit[@]:1}"
d+='"'
else
d='${sPlit[@]}'
fi
#end of hacky fix
rm -f "$f"
eval "$d"
}
other than that, I love the program! and I'm hoping I can learn to further customize it more! Likewise I wan't to ask if we can access the path name other than the directory name when creating new verbs like {file} uses?
Thank you :)
In the next few days|weeks|centuries, I'll be attempting this.
This will involve replacing termion with crossterm or pancurses... and do many changes.
The hardest case will be the one where the terminal must be given to the editor (vi, emacs, etc.).
In the meantime #37 would offer a workaround
That's something I've been asked for a few times.
I'd need somebody with a mac to look at it and propose a solution for package generation and maintenance, I have no idea how macs work those days...
@lovasoa maybe?
With tab you can go to the next match.
I expected shift-tab to go to the previous one.
Compiling broot v0.8.4
error[E0609]: no field table_border
on type termimad::skin::MadSkin
Attempted to access a non-existent field in a struct.
Erroneous code example:
struct StructWithFields {
x: u32,
}
let s = StructWithFields { x: 0 };
println!("{}", s.foo); // error: no field `foo` on type `StructWithFields`
Hello! Thanks for writing this tool, it's novel and I'm excited to use it more. I am wondering if you're open to a helper flag in broot
itself that outputs the entire br
shell function to standard output. With this flag (let's call it --shell-helper
for example), you could recommend users set up broot by downloading the binary and running broot --shell-helper | tee -a ~/.bashrc
or similar. For additional flexibility, you could even read the value of the $SHELL
env variable and output a version of br
that's compatible with the user's shell (if it's not bash
).
Since looking for a directory and :cd
ing into it is one of Broot's main usecases, I think there should be a shortcut for it - a quicker way to access that functionality than :cd<enter>
. Either add a ctrl+<something>
shortcut, or make pressing <enter>
on the current root directory :cd
that directory.
Steps to reproduce:
Hit <esc> to quit
<down>
to select the first file. The status line says Hit <enter> to open the file
.<up>
to select the current folder again. The status line now incorrectly says Hit <enter> to quit
, which doesn't do anything.Right now, the filter is not preserved in the resultant tree view's input area if you pass a filter directly to br as an argument, like so:
br -c "miaou :g" ~
This means if you need to to alter the filter query in any way (like turning on exact matching by terminating with a '/'), you need to retype the entire filter from scratch.
The filter works as expected, but I think it would be useful to preserve the filter in the input area for subsequent modification.
Thanks for your consideration.
Is everything clear?
We prefer you come to the chat and speak about the problem first.
Broot chat room: https://miaou.dystroy.org/3490?broot
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Configuration (please complete the following information):
Additional context
Add any other context about the problem here.
It would be great if the folders and files could be sorted by size, instead of by name.
I tried
[[verbs]]
name = "open"
invocation = "open"
shortcut = "<enter>"
execution = "vim {file}"
But did not succeed.
Allow configuration of color of selection bar.
My terminal has a dark background color.
Now the selection bar is not very visible.
Exiting with :pr works as normal (autocompletes to :print_path) and prints to stdout when no output file is set. However, if a file is supplied with -o, you must type the full :print_path command in order to get broot to print to the file.
I think that the expected behavior should be that the destination file is created if it does not already exist when "-o {FILENAME}" argument is passed.
Instead, if you supply a file that does not exist yet, you get an IO Error:
# br -o result.txt
IO Error : "No such file or directory (os error 2)"
Make a release for Mac OS X, maybe a brew package if possible.
Curious whether there's interest in a feature to toggle whether directories are collapsed or not. For example, it'd be nice to be able to collapse all directories in the current root -- so you'd only see files and directories directly in the current root. It would also be nice to be able to toggle whether a directory is collapsed so you could quickly check the first few files in a directory.
My use case for this would be general navigation of code projects, especially in the context of introducing a new codebase to someone. It's really nice to be able to see a project's structure and focus on specific directories in these cases, and this ability to control collapsing of directories would help that a lot.
Sometimes it is useful if the fuzzy search could be disabled (like :toggle_hidden
), so you can search for exact matches only.
Example: directory with a lot of subdirs which contain the date.
The "unlisted" bit where broot
truncates the contents of a directory sure is useful, but could we also have an option to display and browse (with paging?) the entire contents of a directory? Some directories just have a lot of subdirectories and files, and just now I found myself wanting to go through the listing manually instead of searching, because I didn't know what I was looking for. For now it's back to ls -a
for me, but I was hoping I could use broot
's interactive tree view :)
Regex capture groups in the invocation in custom verbs are not parsed at all when using --cmd
.
For instance, this custom verb:
[[verbs]]
name = "mpv"
invocation = "mpv (?P<args>.*)"
execution = "mpv {args} {file}"
from_shell = true
With this this cli command:
br --cmd "somefile.mp4 :mpv --loop"
Will pass the literal string {args}
to mpv, instead of the expected behavior of matching and substituting --loop
.
Thanks for your work.
It's not clear to me after reading the docs how to change the default file opener to "code" (VSC) or vim
is this possible?
In the automatically generated config the following link is given:
https://github.com/Canop/broot/documentation.md
This link does not work. It should probably be replaced with https://github.com/Canop/broot/blob/master/documentation.md
or similar.
When exiting broot using :c
, it outputs the selected path to stdout, but it might additionally print a (partial) panic message because an internal thread appears to panic:
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', libcore/result.rs:1009:5
Unfortunately I can't get a backtrace since broot exits during the panic.
Fixing this is probably only a matter of ignoring this kind of error or exiting the threads in a different fashion that can't cause this.
The rm
command should remove the selected file, even when it's a link.
Instead it removes the target.
Trying to open text-files will result in a 'blocking' freeze of broot, without the expected result. Meaning: broot does not need 100% CPU (rather 0%), but does not react to any actions (deleting letters, adding new ones) tried. The opening of the selected text-file does not happen either. Only solution found: killing the terminal.
Steps to reproduce the behavior:
My preference:
Also okay:
My assumption as to why this is happening is because broot does not exit in this case, and xdg-open intends to open vim in this terminal. This might result in broot waiting for xdg-open to finish 'opening', and xdg-open waiting for broot to release the terminal, which does not happen.
Currently, when broot tries to launch an external executable and fails (because the executable is not present), it displays :
Os { code: 2, kind: NotFound, message: "No such file or directory" }
This message is not very user-friendly, and it would be more helpful if t contained the name of the missing executable. Something like:
Unable to launch /usr/bin/nvim: No such file or directory (os error 2)
Did a discussion occur before?
No
Is your feature request related to a problem? Please describe.
I am usually deeply in a nested structure and I can't find stuff on the disk.
Describe the solution you'd like
I was searching for a button eg. the Home-Key to jump into my users home directory to start the search there.
Describe alternatives you've considered
I read about shortcuts, but the docs are not good enough for a 5min fix.
Additional context
I like this project so far, please add more docs and explain better why the service is needed.
Currently, broot
creates a config file with edit
and view
tools predefined. I think, for most users the default/expected behaviour would be to use tools set in EDITOR
(with fallback to vi
?) and PAGER
(with fallback to less
?) environment variables.
Reference: https://no-color.org/
Those abilities would be useful, at least to me:
Those would be easily achieved with broot just storing the last opening path in .config/broot
. It's possible one of those commands would be enough (I don't want to add dozens of commands to the shell).
It seems, that currently only bash and zsh are supported. I usually use the fish shell.
I looked a bit into it and ported the bash script to fish:
function br
set f (mktemp)
broot --outcmd $f $argv
if test $status -ne 0
rm -f "$f"
return "$code"
end
set d (cat "$f")
rm -f "$f"
eval "$d"
end
I saved it to ~/.config/broot/launcher/fish/br
and also added this into my ~/.config/fish/fish.config
:
source /home/<username>/.config/broot/launcher/fish/br
The integration to the broot --install
command is missing.
Currently I'm not able to integrate it into the broot code base, but I wanted to leave it here as a starting point for someone else. Maybe I also find some time to work on it myself, but we'll see.
Launching commands via a verb that write to stdout does not work (or at least does not show the output). Programs which are using ncurses, like top, tmux, nano show up correctly:
# Does not work.
[[verbs]]
name = "list"
invocation = "l"
execution = "ls -l {file}"
# Does not work.
[[verbs]]
name = "cat"
invocation = "C"
execution = "cat {file}"
# Works.
[[verbs]]
name = "top"
invocation = "t"
execution = "top"
MacOS does not have an xdg-open
script by default.
I would suggest using the opener crate to open files with their default editor in a platform-agnostic manner.
Hey! ๐
You have implemented a nice tool. It is a great and light alternative for solutions where fzf is not enough and ranger too much.
I'm just about to configure it and this includes for me adding its configuration to my dotfiles repository. I happily assert that you support the XDG-Directory standard. But this $XDG_CONFIG_HOME
does contain not only user configuration. Also the launcher
directory with the shell script for the br
functions is included. For me this is not part of the user configuration and more a shared source. At least I will overwrite this and export to another location. But this is cumbersome and I must handle this specifically in my dotfile manager. I would suggest to use $XDG_DATA_HOME
for example. Or even share it between all user in /usr/share/
like many other tools are doing as well.
I have installed fish from Manjaro repository. In ~/.config/fish/
. I have no config.fish
file, instead I place configuration in .fish
files in ~/.config/fish/conf.d/
. broot --install
fails as it is looking for config.fish
file.
After copying FISH_FUNC into new file (e.g. ~/.config/fish/conf.d/br.fish
) and restarting fish, it works.
I think fish supports conf.d
out-of-the-box, so broot --install
should:
conf.d
if it doesn't existbroot.fish
existsFISH_FUNC
thereFISH_FUNC
, if not, report error to userrelated #31
Hi and thanks for the app.
Sorry for the unclear title, but I'll try to explain. I added this to my .zshrc file:
function _brootize() {
myargument=`echo $BUFFER | awk '{print $2}'`
echo `broot --cmd $myargument` # + maybe a trick to print the filename only
}
zle -N _brootize
bindkey '^[b' _brootize
So when I write a command like vim myfile.py
and press the hotkey (in this case Alt-B), I wanted to run broot --cmd myfile.py
automatically with "myfile.py" applied for fuzzy searching. After I select the file it should drop me to the terminal with vim full/path/to/myfile.py
instead of running br/broot everytime and supplying the mandatory verb after space.
But since broot requires some terminal to display stuff (and I am a failed potato to redirect tty/pts) all I got is: IO Error : "Inappropriate ioctl for device (os error 25)"
when I try this.
Is there any way to accomplish this? Maybe with different way so we can already start using broot as generic fuzzy completion tool.
Fyi: I wanted to check if there is a similar discussion, but https://miaou.dystroy.org/3490?broot is not working for me
In order to use broot
as a CLI tool (the Unix philosophy!), we would need an option to make broot
print the selected path into stdout, rather than simply opening it as a Desktop application. (I think it should be a default behavior)
Please see fzf for an example.
Currently you can move through entries with the mouse scrollwheel, i think i would make sense to complement it with the ability to select an entry with the mouse click. It would make working with the mouse much more productive.
Given a file abcdefg.123
, typing ab3
does not match anything.
Steps to reproduce:
# mkdir /tmp/test
# cd /tmp/test
# touch abcdefg.123
# broot
ab3
broot integrates nicely with fzf-marks for bookmarking using a custom verb as follows:
[[verbs]]
name = "mark"
invocation = "mark"
execution = "cd {directory} && mark"
from_shell = true
However, 'mark' can take an argument which is then used as the name of the bookmark. If you try typing :mark {mybookmark_name}
, broot does not recognize that a verb has been typed.
In other words, being able to pass on the text that follows a custom verb would be a useful feature.
In fact, the ability to capture the text after a verb would more generally enable the ability to execute an on-the-fly command with the current directory or file as the trailing argument. E.g. a 'multipurpose' verb with the execution syntax something like: execution = "{command} {file}"
(where {command} is the trailing text after the verb) would enable things like: :custom mpv --loop
I think this is a way of greatly enhancing the flexibility of broot without needing to be able to capture paths from stdout.
Thanks for your work and for your consideration.
I try to install broot on a windows machine. Therefore I'm using the crossterm branch right now.
The only thing that prevents me from installing it is that I don't have a C-compiler installed. Because of the dependency of jemallocator it is required to have one sadly.
I would like to see an optional feature, where you can tell to not use jemallocator.
The alternative would be to install a C-compiler, I don't want that :)
This one should be very easy.
Just add a feature in https://github.com/Canop/broot/blob/master/Cargo.toml, make it a default feature and put
Lines 1 to 2 in e77e656
behind that feature gate
It would be great to make the app more CLI-friendly. For example,
Reference: https://caiorss.github.io/Emacs-Elisp-Programming/Keybindings.html
Note that many CLI programs that works on a bash/zsh shell are compatible with these keybindings.
First I cloned the repo and tried to run cargo build --release
and got this error.
error: failed to parse manifest at `/usr/home/gregf/broot/Cargo.toml`
Caused by:
editions are unstable
Caused by:
feature `edition` is required
this Cargo does not support nightly features, but if you
switch to nightly channel you can add
`cargo-features = ["edition"]` to enable this feature
Next I tried to use the cargo install command since it's on crates.io
Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to parse manifest at `/home/gregf/.cargo/registry/src/github.com-1ecc6299db9ec823/broot-0.4.2/Cargo.toml`
Caused by:
editions are unstable
Caused by:
feature `edition` is required
this Cargo does not support nightly features, but if you
switch to nightly channel you can add
`cargo-features = ["edition"]` to enable this feature
If your .gitignore contains
a/b/c
(that is a multi-token pattern not starting with a /
)
then git would ignore the
$project_root/a/b/c
file, but broot wouldn't filter it out.
This looks like a limitation (a bug?) of the glob lib I use (https://docs.rs/glob/0.2.11/glob/).
In broot interactive mode, you can type a query like "test:s" and it will display results for "test" and toggle sizes. However, neither the "test" filter or the size toggle will register in broot if you start broot like so:
br -c "test:s"
However, this command works as expected:
br -c "test :s"
Thanks.
Since I'm using NixOS, none of the binaries are where broot expects them.
It would be nice if I could put:
[[verbs]]
name = "mkdir"
invocation = "md"
execution = "/run/current-system/sw/bin/mkdir -p {directory}/{subpath}"
in my config and have it override the default.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.