Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
A terminal file manager written in bash (github.com/dylanaraps)
107 points by mrjblack on Oct 24, 2018 | hide | past | favorite | 43 comments


Ranger has taken over my world the past few years. Heck I even have it working in Windows 10 in the Linux Subsystem (OpenSUSE for me). Ranger for me is just as fast in real life and my work Windows 10 machines are not anything to write home about.


Link for anyone like me who's never heard of it before: https://github.com/ranger/ranger


it's also already packaged in most distributions if you want to install it easily.


I've used Ranger in the past but eventually went back to Midnight Commander. From a usability point of viewer nothing compares with a fixed 2 panels file list.


If you're on Windows Far manager is amazing. It's really customizable too with plugins and shortcuts. I rarely use Windows these days so I had forgotten about it, but it's like midnight commander taken to another level.


Would you mind taking a minute to explain why you needed a tool like this in the first place, please? I'm quite interested.


There's exhaustive reasoning in the readme: ¯\(ツ)/¯


One use case: I often use Midnight Commander via ssh to my file server. If I move a file on my local machine via NFSv4, it will still pull all the data to my box and back out to the file server.

Command line file managers are nice because when I move a file, it's all done on the remote box (and hence, faster).


given that this is only 100 lines of code i am quite impressed.

however, i miss one feature for which i'd use a filemanager: in-place file renaming. in most cases when i want to rename a file, i want to change a small part of it, and i don't want to have to retype the whole filename.

i have yet to find a commandline utility (emacs doesn't count ;-) that offers that.


No need for a filemanager for in place file renaming. For that I'd just use curly bracket in bash or zsh.

e.g.

  mv /path/to/file{-old-name,-new-name}.txt
which expands to:

  mv /path/to/file-old-name.txt /path/to/file-new-name.txt

So use tab completion to get your path then go back and stick your curly brackets into it as needed. Oh and it works for things like git branch renaming or anything else you do in the terminal.


If you're a zsh user you can also use the other zshparam(1) stuff too. Like "mv file.ext{,(:r)}" to perform "mv file.ext file", or :l to lowercase a filename, or any number of other sometimes useful or often pointless things ;) I've used :l a number of times, but :s for substition is probably the most useful in general.


thanks, but that takes more conscious effort to get right that is worth it for me. i tend to just copy the filename twice and then edit the second version to the target.

but now i'll become good friends with qmv

greetings, eMBee.


If I'm understanding you correctly, then imv[1] is a great tool for this. 'imv $filename' pops you in to a readline enabled prompt to edit $filename. Given that it is readline you can even add extra options in your ~/.inputrc to add additional features to it, I have mappings for custom dir prefixes as an example.

It also comes with qmv, which will pop open an editor for you to perform inplace edits on filenames. Which is kinda like dired as an emacs comparison, at least if you squint an awful lot.

1. http://www.nongnu.org/renameutils/


those are exactly like what i had in mind. thanks!

qmv even handles swapping filenames which ranger doesn't.

greetings, eMBee.


Tab is your friend! At least in zsh it manages file name completion well - including cycling through options of there is more than 1 match for your partial name.

Of course, you could get more advanced with parameter tricks, eg. ${i%.ps}.pdf for changing the extension of $i from ps to pdf. (Technically: truncating the ending iff it matches ".ps" and adding ".pdf" no matter what.)


Perl has shipped with a `rename` utility for ages, that you can use like:

    rename 's/foo/bar/' *.ext
Of course you have to know Perl...


Put the filename into a shell variable, then sed or split it into characters and then concat.


looks like ranger does it. i'll have a closer look at that


This might hit a sweet spot due to the minimalism. The name is true, too. So it's really fast to open it and do a couple of things and then close it again. That said, I haven't actually used it "for real", we'll see how it fares.


It might be nice if it could obey LS_COLORS so it would match the output of ls.

But this is nice, combining it with micro makes for a dead-easy combo of single-file utilities that I can drop onto a server and more easily move about.


Does this do anything I can't do already via Emacs?


Two things that I always reach for Emacs to accomplish are git and file management, via Magit and Dired(X) respectively. Here's a quick cheat sheet of the things I use Dired for:

    C-x C-j (jump to directory)

    Open the current directory in Dired (requires that
    you first (require 'dired-x)) from any buffer, even
    other directories, but usually from within files.

    C-x C-q (edit directory)

    Start editing the current directory as a plain-text
    buffer and commit changes with C-c C-c or discard
    all changes with C-c C-k.

    One thing you can do with this is quickly swap two
    filenames. Dired will give one of them a temp name
    which is super convenient.

    Combined with multiple-cursors package, this also
    lets you mass rename files in ways that would be
    much harder in terminal.

    d (delete)

    Mark items in directory for deletion, (x) to commit.

    m (mark)

    Mark items in a directory for:
    
      R - rename (or move)
      C - copy
For a more thorough list, open a directory and type C-h m


Wow, I switched to Emacs earlier this year and have not encountered dired mode before. This is fantasic!



Emacs truly superb for discovering new things. I always try to learn a new Emacs feature every couple of weeks.

I even got my mother-in-law using Emacs!


Run on a machine that doesn't have Emacs installed.


No need to install anything with "Tramp" mode (https://www.emacswiki.org/emacs/TrampMode)


tramp is built into emacs now. Between tramp and helm the problem is solved :-P


But if you install this then you could install Emacs instead, yes?


"Installing" this is as simple as:

  curl 'https://raw.githubusercontent.com/dylanaraps/fff/master/fff' > fff; chmod +x fff
It's a 121 line Bash script, no dependencies. I suspect Emacs is slightly more intrusive than that.


I quickly glanced through it, and there are a few dependancies: /bin/mkdir and /bin/mv (read and nohup are build in Bash). This could be useful for embedded systems and containers. Although Alpine, by default, doesn't come with Bash. Oh, and yeah, it is fast.


>> It's a 121 line Bash script, no dependencies. I suspect Emacs is slightly more intrusive than that.

"Slightly" is a very interesting word to use there :)


¯\(ツ)/¯


I like the vi-inspired commands. I will definitely be trying this out.

I've also had good luck with using the terminal program, vifm, which also uses familiar vi muscle memory in a traditional "commander-style" two-panel layout.

https://vifm.info/


Looks similar to nnn (https://github.com/jarun/nnn), which is written in C with many more features.


I wonder how you come up with this kind of obfuscated source code, does anyone have an idea how it's made?


Lol, video shows lots of pirated content.


How fast is "fucking fast?" Metrics please! :P


bash/10


no feature to shell into a directory ? that'd be useful


or read mail


Bad idea. Bad


why?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: