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

Any way to toggle show/hide hidden directories and files? #8

Open
pfr-dev opened this issue Oct 18, 2024 · 16 comments
Open

Any way to toggle show/hide hidden directories and files? #8

pfr-dev opened this issue Oct 18, 2024 · 16 comments
Labels
enhancement New feature or request

Comments

@pfr-dev
Copy link

pfr-dev commented Oct 18, 2024

Firstly, let me just say thank you. This program is awesome and I will be switching to it permanently once it's close to feature complete. I've used nnn, fff, shfm, ranger, lf etc. for a long time. But this implementation using the tree is just awesome!

I wonder if it could be possible to toggle show/hide hidden dirs and files? that would be neat. I assume that if you're leveraging the tree command then simply dropping the -a flag should do it?

I'm also excited for you're implementation of image previews.. I'm curious what route you might take for this?

EDIT
I'm also curious how to set default programs for opening files? for example, I'm attempting to open an image file but it obviously doesn't know with which program to open it. where can I set this? Is there an opener file that it needs to read?

@LeperGnome
Copy link
Owner

Hi! Thanks a lot, I'm really glad, that you like this project!
First of all, no, I'm not using tree, all the rendering is custom, so I would not be able to just drop -a, but regardless, toggling hidden files view should not be too hard to implement.

About image previews - yea, I'm also excited about this! I wasn't giving it too much yet though, but currently I think that I'll choose different strategies depending on terminal emulator with a fallback of covering image to a set of colorful half-blocks. You can share your suggestions!

About opening files - currently bt only opens files in $EDITOR on e, because it's a primary use-case... for me =) I'll definitely implement opening files with different programs (leveraging open? Not yet sure)

@pfr-dev
Copy link
Author

pfr-dev commented Oct 18, 2024

Yeah these days you've got to cover all bases when it comes to images in the terminal. Kitty image protocol, sixel, ueberzug++, chafa etc... is a bit of a task I know.

However, implementing the use of an opener script first would say least allow the user to open image files with an image viewer.

I use my terminal for browser to open all files, PDFs, XMLs, PNGs.. anything. So an opener script would be great. using XDG_OPEN would also work, but I l personally prefer to have fine grained control using a script.

I currently use the following script with shfm and fff

#!/bin/sh -e
#
# open file in application based on file extension

case $(file -bi "$1") in
    image/png*|image/jpg*|image/jpeg*)
	feh -g 700x393 --scale-down "$1"
    ;;
    text/*)
    "${EDITOR:=vim}" "$1"
    ;;
    audio/*)
	mpv --no-video "$1"
    ;;
    video/*)
	mpv --geometry=700x393 "$1"
    ;;
    *.html)
    firefox "$1"
    ;;
    *.pdf)
	zathura "$1"
    ;;
    *) # all other file types
    xdg-open "$1"
    ;;
esac

@LeperGnome
Copy link
Owner

Noted, thank you! Customizable openers for different filetypes look great, I would love to implement it!

@LeperGnome
Copy link
Owner

@pfr-dev Hey! I sat down to think about your feature request and made a quick PR, but I'm kinda hesitant... I'll be glad if you cared to look at my approach and let me know what you think. Do you think, that toggling is fine (or even better) only for current directory and not the whole tree?

@LeperGnome
Copy link
Owner

Work kinda like this. As you can see, I can toggle hidden files only on a single "depth level".
Screencast from 18.11.2024 02:36:03.webm

@pfr-dev
Copy link
Author

pfr-dev commented Nov 18, 2024

Hmmmm cool idea! But... I think if you want to only toggle hidden files within a current directory, then it should also include all subdirectories. Otherwise, it might get confusing if you have to keep toggling fore every subdirectory.

What to you think?

@LeperGnome
Copy link
Owner

I'm not sure here. What if you want to disable hidden for current, and enable for children? You will just need to toggle it in every child. So I think, that it's more or less the same in terms of functionality, could be a bit more confusing from my perspective, but if I'm being honest, I don't necessarily like either option xD

I looked at how it's done in ranger, and, well, it's just easier to implement, since there's max of 3 opened directories shown on the screen, so they can just refresh all 3.

@LeperGnome
Copy link
Owner

May be I could make some sort of indicator, that will show, that hidden directories are actually hidden... Idk, need to experiment

@LeperGnome
Copy link
Owner

The small dot near the directory name to indicate, that hidden files are not shown at this level. Exciting? Not for me really, but might get the job done. (p.s. hated all the emojies and larger signs)
image

@pfr-dev
Copy link
Author

pfr-dev commented Nov 21, 2024

I guess here-in lies the problem with a tree style file manager. If you've got Lots and lots of files, it quickly becomes difficult to navigate. But I see what you're saying, and I agree, an indicator to let you know that a directory contains hidden files is a good idea and your example above looks perfect!

I have one more suggestion which might help with space saving while navigating large directories.

Please let me know if you'd like me to split this into another issue, but for now I feel it's kind of relevant here.

What if, when you navigate to a subdirectory, the parent directory collapses, only showing the name of the parent directory but not every other subdirectory there within?

@LeperGnome
Copy link
Owner

Well, It's an interesting idea, but if I understood you correctly, it will just remove all the other context, that could be helpful. E.g. I want to move ./pkg/stack/stack.go to ./cmd/bt/main.go. Then, instead of seeing this, and being able to plan all my movements

.
├─ .git
├─ assets
├─ bin
├─ cmd
│  └─ bt
│     └─ main.go
├─ internal
├─ pkg
│  └─ stack <-
│     └─ stack.go
├─ test
├─ .gitignore
├─ go.mod
├─ go.sum
├─ LICENSE.txt
├─ Makefile
└─ README.md

I'll see this:

.
├─ pkg
│  └─ stack <-
│     └─ stack.go

No real point of having a tree structure with such rendering.
Please correct me if I misunderstood you

@LeperGnome
Copy link
Owner

LeperGnome commented Nov 22, 2024

I think, that if space is the issue in large directories, then it may be should be solved by other means, like faster up/down movement (like Ctrl+u/d in vim), or searching filename, or leaving marks.
I honestly just really like how file trees look, It's a very intuitive representation and I don't want to give it up =)

@pfr-dev
Copy link
Author

pfr-dev commented Nov 22, 2024

Yeah ok, you're right (again!) haha I think this works well. The indicator idea is great because I'll generally know which subdirectory my needed dotfiles are so I can just expand that particular dir instead of all of them.

Has this been implemented in the master tree yet? Would love to test it out.

I'm really excited for this. Can't wait until you've ticked everything off the TODO list!

Oh, and also rewrite it in Rust 🦀 😆

@LeperGnome
Copy link
Owner

LeperGnome commented Nov 22, 2024

Has this been implemented in the master tree yet? Would love to test it out.

nope, just in pr yet #9

Thanks man, I really appreciate your interest in this project!
I actually initially started writing a similar program in rust - trre, but recursive data structures are just a paint to work with there (or it's my skill issue, most likely), so I switched to go, GC just makes life easier =)

@pfr-dev
Copy link
Author

pfr-dev commented Nov 22, 2024

Back on the custom opener script suggested earlier.. Why not just have a bt.conf config file where you can set default programs for opening files as well as being able to customize the keybindings? I'm one of those weirdos who likes to swap j and k in my .vimrc so I'd love to have the ability to tweak the keybindings also.

Oh, and one more!... cd to current dir on exit

I often will just use nnn to navigate to a deep directory instead of typing out the full path. Please add this to the TODO 🙏
EDIT: I just saw - [ ] Jump to current directory in the TODO... 🥳

@LeperGnome
Copy link
Owner

LeperGnome commented Nov 22, 2024

Yea, I would love to add more customization!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants