Git Product home page Git Product logo

broot's Introduction

Broot

Tests MIT Latest Version Chat on Miaou Packaging status

A better way to navigate directories

Complete Documentation - Installation Instructions - Contributing or Getting Help

Get an overview of a directory, even a big one

Hit br -s

overview

Notice the unlisted?

That's what makes it usable where the old tree command would produce pages of output.

.gitignore files are properly dealt with to put unwanted files out of your way.

As you sometimes want to see gitignored files, or hidden ones, you'll soon get used to the alti and alth shortcuts to toggle those visibilities.

(you can ignore them though, see documentation).

Find a directory then cd to it

type a few letters

cd

Hit altenter and you're back to the terminal in the desired location.

This way, you can navigate to a directory with the minimum amount of keystrokes, even if you don't exactly remember where it is.

Broot is fast and doesn't block (any keystroke interrupts the current search to start the next one).

Most useful keys for this:

  • the letters of what you're looking for
  • enter on the root line to go up to the parent (staying in broot)
  • enter to focus a directory (staying in broot)
  • esc to get back to the previous state or clear your search
  • and may be used to move the selection
  • altenter to get back to the shell having cd to the selected directory
  • alth to toggle showing hidden files (the ones whose name starts with a dot)
  • alti to toggle showing gitignored files
  • :q if you just want to quit (you can use ctrlq if you prefer)

Never lose track of file hierarchy while you search

search

Broot tries to select the most relevant file. You can still go from one match to another one using tab or arrow keys.

You may also search with a regular expression. To do this, add a / before the pattern.

And you have other types of searches, for example searching on file content (start with c/):

content search

You may also apply logical operators or combine patterns, for example searching test in all files except json ones could be !/json$/&c/test and searching carg both in file names and file contents would be carg|c/carg.

Once the file you want is selected you can

  • hit enter (or double-click) to open it in your system's default program
  • hit altenter to open it in your system's default program and close broot
  • hit ctrl to preview it (and then a second time to go inside the preview)
  • type a verb. For example :e opens the file in your preferred editor (which may be a terminal one)

blog: a broot content search workflow

Manipulate your files

Most often, when not using broot, you move your files in the blind. You do a few ls before, then your manipulation, and maybe you check after.

You can instead do it without losing the view of the file hierarchy.

mv

Move, copy, rm, mkdir, are built in and you can add your own shortcuts.

Here's chmod:

chmod

Manage files with panels

When a directory is selected, do ctrl and you open another panel (you may open other ones, or navigate between them, with ctrl and ctrl).

custom colors tree

(yes, colors are fully customizable)

You can for example copy or move elements between panels:

cpp

If you like you may do it Norton Commander style by binding :copy_to_panel to F5 and :move_to_panel to F6.

Preview files

Hit ctrl when a file is selected and the preview panel appears.

preview

preview

The preview panel stays synchronized with the selection in tree panels.

Broot displays images in high resolution when the terminal supports Kitty's graphics protocol (compatible terminals: Kitty, WezTerm):

kitty preview

Apply a standard or personal command to a file

size

Just find the file you want to edit with a few keystrokes, type :e, then enter.

You can add verbs or configure the existing ones; see documentation.

And you can add shortcuts, for example a ctrl sequence or a function key

Apply commands on several files

Add files to the staging area then execute any command on all of them.

staging mv

Replace ls (and its clones):

If you want to display sizes, dates and permissions, do br -sdp which gets you this:

replace ls

You may also toggle options with a few keystrokes while inside broot. For example hitting a space, a d then enter shows you the dates. Or hit alth and you see hidden files.

Sort, see what takes space:

You may sort by launching broot with --sort-by-size or --sort-by-date. Or you may, inside broot, type a space, then sd, and enter and you toggled the :sort_by_date mode.

When sorting, the whole content of directories is taken into account. So if you want to find on Monday morning the most recently modified files, launch br --sort-by-date ~.

If you start broot with the --whale-spotting option (or its shortcut -w), you get a mode tailored to "whale spotting" navigation, making it easy to determine what files or folders take space.

Sizes, dates, files counts, are computed in the background, you don't have to wait for them when you navigate.

size

And you keep all broot tools, like filtering or the ability to delete or open files and directories.

If you hit :fs, you can check the usage of all filesystems, so that you focus on cleaning the full ones.

fs

Check git statuses:

Use :gf to display the statuses of files (what are the new ones, the modified ones, etc.), the current branch name and the change statistics.

size

And if you want to see only the files which would be displayed by the git status command, do :gs. From there it's easy to edit, or diff, selected files.

gg

From there it's easy to edit, diff, or revert selected files.

blog: use broot and meld to diff before commit

Further Reading

See Broot's web site for instructions regarding installation and usage.

broot's People

Contributors

0x1da117 avatar 0xflotus avatar 9999years avatar akx avatar allonhadaya avatar arnej avatar asdf8dfafjk avatar atahabaki avatar azdavis avatar canop avatar creideiki avatar danielzgtg avatar dependabot[bot] avatar eldad avatar fabulouscupcake avatar felixkroemer avatar francescelies avatar goggle avatar guillaumecherel avatar herbygillot avatar jonasleonhard avatar kw-andy avatar lovasoa avatar lucretiel avatar max-sixty avatar rgwood avatar roshan avatar spacelord-xan avatar stargateur avatar stevenxxiu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

broot's Issues

Add [Home-Key] shortcut to jump into ~

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.

Opening a text file will freeze broot when xdg-open wants to open with vi in same terminal

Bug-Despriction

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.

To Reproduce

Steps to reproduce the behavior:

  • Set the default for opening text-files with xdg-open as 'vi' or 'vim'. Maybe with 'update-alternatives'.
  • simply try to 'open' (not 'edit', this works fine) a (text-) file. Other files (opening with external programs) also work fine.

Expected behavior

My preference:

  • Open a new Terminal with this file in vim (as does happen when opening text-files from a graphical file explorer)

Also okay:

  • Closing broot and opening vim with this file in this window (same as: editing)

Configuration (please complete the following information):

  • OS: Linux (Ubuntu 18.04)
  • broot v0.9.3
  • vim: NVIM v0.3.8

Assumption

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.

Correct usage of XDG-Directory standard

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.

Can't install

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

MacOSX iterm2 Command-Enter is wired to fullscreen

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):

  • OS: [e.g. iOS]
  • Version [e.g. 22]
  • Relevant configuration items

Additional context
Add any other context about the problem here.

Does not see the lib directory

Does not see the lib directory in the project directory, but if you go up one level, it finds.
scrinshot 1
scrinshot 2
scrinshot 3

ssory. lib directory is registered in gitignore ))

Sort by size

It would be great if the folders and files could be sorted by size, instead of by name.

broot --install doesn't work when fish uses conf.d

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:

  1. create conf.d if it doesn't exist
  2. check if broot.fish exists
    2.1. if not, create it and put FISH_FUNC there
    2.2. otherwise, check if the content equals FISH_FUNC, if not, report error to user

related #31

A way to use broot as inline selector?

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

Problems with 'cd' into paths with spaces in them

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 :)

launcher for fish 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.

Panic (sometimes) when using `:cd` without the companion shell function

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.

Add a shortcut for `:cd`

Since looking for a directory and :cding 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.

Feature request: Pass any text following a custom verb to the execution command

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.

Feature request: Collapse/uncollapse directories

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.

Documentation link broken

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.

`--version`/`-V` flag broken in the 0.6 release

running broot --version produces:
image

...Also, broot tries to do the setup of the cd function if it hasn't been setup when attempting to get print the version. This behavior broke a bash script I had that checked the version to see if this tool (and others) need updating

Allow to toggle to exact search mode.

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.

shell command to cd/broot back to before last broot move

Those abilities would be useful, at least to me:

  • get back in the shell to where I was before last navigation done with broot
  • open broot on the last opened path (before last navigation which might have been done with alt-enter)
  • open broot on the last state (including filtering)

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).

Regex capture groups in custom verbs are not parsed when using `--cmd`

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.

Make broot install the shell helper function

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).

allow selection by mouse click

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.

Print selected path to stdout

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.

Launching commands via a verb that write to stdout does not work.

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"

When a command fails to launch, display its name

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)

homebrew package for Mac

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?

When -o is set, create the output file if it does not exist

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)"

Preserve the filter in the tree view input area after passing it as an argument to broot

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.

Feature request: Feature gate jemallocator

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

broot/src/main.rs

Lines 1 to 2 in e77e656

#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;

behind that feature gate

Allow full directory listing

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 :)

Windows compatibility

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.

Feature request: allow user to override verbs

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.