Settings

Theme

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

github.com

75 points by dankco 2 years ago · 30 comments · 1 min read

Reader

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

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.

  • dankcoOP 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.

  • dankcoOP 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?

  • dankcoOP 2 years ago

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

  • dankcoOP 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

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/

  • dankcoOP 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

    • blooalien 2 years ago

      Midnight Commander also includes a really decent little text editor (mcedit) with syntax highlighting for a decent range of text file formats.

    • alchemist1e9 2 years ago

      nnn could be another to compare against.

    • visarga 2 years ago

      How about Norton Commander?

      • Brian_K_White 2 years ago

        Same thing. MC was made to emulate NC. And of course there are actually countless filesystem browsers. Even xtree was probably not the first since that was on ms-dos, and I bet there were some on the 8-bit machines before that.

        But this one's aim seems to be a bit specific and not simply to be a filesystem browser (file manager) but specifically to try to be an "interactive ls". IE somehow feel like ls. Though I don't know why. It doesn't seem more useful than a normal file manager. I think it's just down to a very fine point of aesthetics, which is fair enough.

  • 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

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection