top | item 37675465

Show HN: Nav – A terminal navigator for interactive `ls` workflows

75 points| dankco | 2 years ago |github.com

Hi Everyone,

I built a tool for interactive navigation in the terminal that is intended to replace the all-too-familiar cycle of `ls` to view a directory, followed by `cd`, then `ls`, and repeat.

nav is a terminal filesystem explorer built for interactive `ls` workflows. The key features I wanted to enable are interactivity and search without feeling like I'm using anything other than `ls`. nav supports common `ls` options/flags, as well as tab completion, and might expand its support for less common options in the future. These options exist as both CLI flags and interactive toggles.

nav works as a standalone tool or in a bash/zsh pipe or subshell to e.g., change directories, copy a file name to the clipboard, etc. For example, I use the simple functions from the README in my .zshrc for interactive `cd` and copy-to-clipboard workflows.

nav was inspired by the discussion of the excellent `walk` [0] tool and was written from the ground up to support its `ls`-centric interactive feature set. I hope you might find it useful and I'd love to take any feedback or suggestions that might come to mind!

[0] https://news.ycombinator.com/item?id=37220828

28 comments

order

jraph|2 years ago

Seems nice :-)

For this part specifically:

> the all-too-familiar cycle of `ls` to view a directory, followed by `cd`, then `ls`, and repeat

I use (oh-my-)zsh for this. Tab would autocomplete (with some basic support for "fuzzy search" - case insensitive, part for the file works). If there are several options it displays them and they can be selected. When completed, another tab press displays the folder content. For some commands, it tries to show only relevant files. For cd, it won't complete with the name of a (non-folder) file.

This is very effective. I feel like one of my hands is missing when I don't have this, for instance when I'm using bash.

dankco|2 years ago

I agree! nav supports this workflow in search mode as well, and I could easily support fuzzy searching rather than exact match if that would be valuable.

linhns|2 years ago

Decent effort. Have you tried looking at fzf? I managed to combine it with ripgrep to create a similar experience to what you have.

dankco|2 years ago

Yes, fzf and ripgrep are the best! Together they are the heart of at least half of my .zshrc functions, and it would be fun to see about writing something similar by composing them together in various ways. Great idea!

metadat|2 years ago

Can you share your full bash or Z fu to merd these creatures?

Gratzi, amigo.

shashurup|2 years ago

Looks interesting.

Have you thought about implementing marks, so that you can select some files for further operations?

dankco|2 years ago

I love this idea and will look into implementing it in the next few days! Thanks!

dankco|2 years ago

Thanks again for the great suggestion. I've implemented this and it is part of the latest release (v1.1.0).

cstrahan|2 years ago

Nice! For inspiration, you may want to look at `lf`: https://github.com/gokcehan/lf

pxc|2 years ago

Also Broot, which is-- like OP's tool-- intended as an ls replacement rather than a full file manager: https://github.com/Canop/broot

dankco|2 years ago

Thanks! This does look like a similar tool, and as you said, I love seeing what others have done for inspiration for new features to tools I'm working on. Thanks again.

turboponyy|2 years ago

There's also ranger and yazi.

janderland|2 years ago

I’ve used ranger for years, even fixed a bug I found while using it.

For my work patterns it’s too feature rich. I only use it for browsing directory structures. Everything else just gets in the way because I haven’t taken the time to learn the other features.

djbusby|2 years ago

Any thoughts on Midnight Commander?

https://midnight-commander.org/

dankco|2 years ago

I have to admit that I had not come across midnight-commander. It certainly looks interesting and I'll be giving it a spin. Thanks for pointing me in its direction!

I do intend to expand nav's feature set to come close to an `ls` replacement, at least for the most common workflows, whereas midnight-commander and other similar tools are perhaps closer to being (or are) file managers. I'm also hopeful that by using the completely awesome Charm [0] libraries that I can make for a pleasing/modern UI. Either way, I had a blast building nav and look forward to continuing on.

Thanks again for the comment!

[0] https://github.com/charmbracelet

renewiltord|2 years ago

It can edit zip files and stuff. I actually had no idea it was a Miguel de Icaza project. Quite a prolific fellow.

pmarreck|2 years ago

Someone stick this up on search.nixos.org! Love me some good CL tooling