Show HN: Fff – A terminal file manager written in bash
github.com
github.com
For those wondering "Why bash?"; I wanted something I could 'wget'/'curl' on other machines that would "just work". The program only requires 'bash 3+' and a POSIX compliant 'coreutils' to function. Also, it's really fun to push bash to its limits!
I'm the developer, happy to answer any questions.
Note: I noticed this has been posted before so I added a '#' to bypass the filter. I think this merits a re-post as the project is 100% different to how it was before. The old program was 100~ lines of obfuscated spaghetti and the new program is around 700~ lines of commented "well structured" code.
Anyways, thanks for the `fff` rewrite, it's pretty wonderful.
Having learned all that you needed to in order to write (and rewrite) this, do you have any similar future projects in the works?
I also hope that people will contribute their own snippets, methods and ideas. It'd be great to find out if there are better ways of implementing the code.
The guide is on GitHub [0] and is a heavy work in progress. Its currently structured in a way I'm not too happy with. I want to change it to a series of 'How to implement x' instead of an ever growing implementation.
Other than the TUI guide I have 4 other major projects which I am working on (neofetch, pywal, fff and the Pure Bash Bible).
I stuck to VT100 sequences (which are supported pretty much everywhere nowadays) with the exception of 1 or 2 newer sequences (which are ignored in older terminals and not required). I didn't want to use 'tput' since it would add the dependency of 'ncurses' and it would slow the program down quite a lot. Each 'tput' call is an external process which adds '10-15ms' to the program per call.
I also ran into some funny bash behavior. The main loop waits for user input (with 'read') and if the script received a 'SIGWINCH' signal that ran a second 'read' asynchronously, it would break the terminal.
The other big issue is you can't write anything widely portable in bash without supporting bash '3.2+' (which is over 10(?) years old at this point). macOS is forever stuck on this version due to Apple's issues with GPLv3. This means useful features like associative arrays, 'declare -n' etc are unavailable for use.
Other than these issues it wasn't that difficult to pull off. It was a lot of fun actually!
I definitely will try it next day. I'm sure it can be my #1 cli file manager!
The current search is just bash creating an array using a glob 'list=(/path/to/current_dir/"$search_query")'. bash gets a lot slower when you start adding more levels to the search (2 or more deep).
I'll get to implementing fuzzy searching algorithms first and we'll see what steps I take from there. Who knows? It might work fast enough in pure bash for file searching.
I also like that I can hit 'l' (or enter) to open files and I don't have to think about what program I need to use to open them. Text files are handled by '$EDITOR' and everything else is opened through mime-type using 'xdg-open' (which is configurable to your opener of choice).