Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to use broot as inline selector? #57

Closed
seqizz opened this issue May 15, 2019 · 6 comments
Closed

A way to use broot as inline selector? #57

seqizz opened this issue May 15, 2019 · 6 comments

Comments

@seqizz
Copy link

seqizz commented May 15, 2019

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

@Canop
Copy link
Owner

Canop commented May 15, 2019

To do this you need to use the shell integration (see https://dystroy.org/broot/documentation/installation/#installation-completion-the-br-shell-function )

You could also define a function directly opening a file with a fuzzy name (calling br --cmd "yourname :e").

It's very similar to what I do go to dirs with dcd: https://dystroy.org/broot/documentation/tricks/#dcd-deep-fuzzy-cd

As for the chat link I'm surprised it doesn't work for you. There are already people discussing in https://miaou.dystroy.org/3490

@seqizz
Copy link
Author

seqizz commented May 15, 2019

Huh, apparently there is something going on with firefox, I was able to open chat with chromium, nevermind 👍

Thanks for the suggestions, dcd is so close to it, but there is a slight catch here I guess:
Currently there is no way to "just print the filename after I choose over TUI".

I've defined following verb:

[[verbs]]
name = "print"
invocation = "_"
execution = "echo {file}"
# leave_broot = false # this didn't work as I expected here anyway :)

and triggered it via broot --cmd "myfile :_", it successfully printed the first match, but I what I'm trying to achieve is to be able to select on the terminal (since my target can be another match which I can see when I run broot --cmd "myfile") so broot can echo that file's name when I enter and quit.

Or maybe I should ask something else. Can I assign "enter" to another verb? 😄

@Canop
Copy link
Owner

Canop commented May 15, 2019

Do I correctly understand that the remaining problem is that you know have to type :_<enter> instead of just doing <enter> ?

And that the problem wouldn't exist at all for you if you could configure the verb mapped to <enter> on files ?

@seqizz
Copy link
Author

seqizz commented May 15, 2019

Do I correctly understand that the remaining problem is that you know have to type :_<enter> instead of just doing <enter> ?

I am not sure what you mean by that, so I'll go with no :) I'll try again.

What I wanted get from broot is: In some way, after I press enter on the selection window, it exits and prints the path of selected file to the stdout. Nothing more.

I assume dcd would benefit from that also. Instead of "I'm feeling lucky" mode, you can run dcd foldername and broot can open its interface to show you all matching folders and let you select the one you'd like to cd into.

And that the problem wouldn't exist at all for you if you could configure the verb mapped to <enter> on files ?

Yes, this way I can map enter button to "echo {file}" so it should work anyway.

Thanks for the patience 😄

@Canop
Copy link
Owner

Canop commented May 15, 2019

This related issue might clarify things: #25

Note that the problem with termion might be solved in a near future as I'm currently rewriting broot to use crossterm instead of termion (and by the way allow windows compatibility).

@seqizz
Copy link
Author

seqizz commented May 15, 2019

Aaah alright. That's exactly what I meant.

I thought it should be trivial since its just printing a generated string to stdout, didn't realize a deeper library problem.

I'll follow the other issue then, thanks! :)

@seqizz seqizz closed this as completed May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants