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

Tree mode? #191

Open
BioBox opened this issue Feb 9, 2023 · 1 comment
Open

Tree mode? #191

BioBox opened this issue Feb 9, 2023 · 1 comment

Comments

@BioBox
Copy link

BioBox commented Feb 9, 2023

Is your feature request related to a problem? Please describe.
I want a way to get a quick view of tree's output that can fit on a single screen. I wrote a shell script for it, but I think that this might offer the best solution. I want to give this program a mode that emulates what my script does whilst retaining the extra shortcuts and interactivity of clifm.

Describe the solution you'd like
Have a tree mode that will prints a recursive tree instead of the standard ls with the eln numbers. This mode should work with the file filters as well to give the user very powerful scanning capabilities. There should also be bindings to increment or decrement the depth level as well.

Describe alternatives you've considered
I wrote a fish shell to view the tree output more comfortably, but I realized that this program has potential to offer a much better solution. Here it is if you wan to see it 😝

function itree --description 'Interactive tree viewer'
    function path_join
	echo (string join / $argv[1] (command realpath --relative-to=$argv[1] $argv[2]))
    end

    set select (tree -nd $argv[1] | sed -e '1d' -e '$d' | fzy | awk '{print $NF}')
    set next (path_join $argv[1] $select)

    # If user selects a deep directory then fill in the missing components
    if [ ! -d $next ]
	set select (fd --prune -t d -g "**/"(basename $next) -1 $argv[1])
    end

    set next (path_join $argv[1] $select)
    set --global tre (realpath $next)

    # Is this the bottom?
    if [ (tree -nd $select | tail -n 1 | cut -d ' ' -f 1) -eq 0 ]
	read -P "It goes no deeper. What do now? (p/l) " response
	switch $response
	    case p
		echo (realpath $next)
	    case l
		ls $next
	end
	return 0
    end

    read -P "What do? (p/t/l/c) " response
    switch $response
	case p
	    echo (realpath $next)
	case t
	    tree $next
	case c
	    itree $next
	case l
	    ls $next
    end
end

If you have fish you can install fd and tree and run it yourself to get a basic idea of what I'm describing.

EDIT: Add command to ensure we're using GNU realpath and not the one supplied by fish.

@leo-arch
Copy link
Owner

leo-arch commented Feb 9, 2023

Hi @BioBox. Thanks for your suggestion.

A built-in tree view mode would be a killer feature, for sure, but it's not planned for now (though it is already in my TODO list). The closest we have, much similar to your script, is a flat view provided by the fzfsel.sh plugin (invoked via the * action). To run this plugin in flat view mode issue:

* -f

But yes, implemented this way (externally) we lose all of clifm's interactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants