You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've always wanted an option to the tree command that limits the output to fit in the screen, sort of to give an overview of the hierarchy without needing to use a pager. This is essentially an optimization form of the subset sum problem, which can be solved in linear time complexity under these restrictions.
What do you think? Would a feature like this be acceptable?
In the meantime I'll use the --filelimit=N option for the tree command, as that can achieve what I want nine times out of ten.
The text was updated successfully, but these errors were encountered:
Never-mind. I wrote a shell script that does what I want, which is to give an overview of the directory structure that fits on the screen.
This will not work in cases where the number of directories on a given depth are greater than the screen height, but that rarely ever happens so this is good enough for 95% of cases.
function itree --description'Interactive tree viewer'function path_join
echo (string join / $argv[1] (realpath --relative-to=$argv[1] $argv[2]))
endset 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 componentsif [ ! -d$next ]
set select (fd --prune-t d -g"**/"(basename$next) -1$argv[1])
endset 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$responsecase p
echo (realpath $next)
case l
ls$nextendreturn 0
endread-P"What do? (p/t/l/c) " response
switch$responsecase p
echo (realpath $next)
case t
tree $nextcase c
itree $nextcase l
ls$nextendend
I should change fd to find but the former is so much better that I can't be bothered.
I've always wanted an option to the tree command that limits the output to fit in the screen, sort of to give an overview of the hierarchy without needing to use a pager. This is essentially an optimization form of the subset sum problem, which can be solved in linear time complexity under these restrictions.
What do you think? Would a feature like this be acceptable?
In the meantime I'll use the
--filelimit=N
option for thetree
command, as that can achieve what I want nine times out of ten.The text was updated successfully, but these errors were encountered: