636 points · by signa11 · 7y ago · 102 comments
- nnn[0] (C) - A terminal file manager, similar to ranger. It allows you to navigate directories, manipulate files, analyze disk usage, and fuzzy open files.
- ncdu[1] (C) - ncurses disk analyzer. Similar to du -sh, but allows for directory navigation as well.
- z.lua[2] (Lua) - It's an alternative to the z utility mentioned in the article. I haven't done the benchmarks, but they claim to be faster than z. I'm mostly just including it because it's what I use.
[0] https://github.com/jarun/nnn [1] https://dev.yorhel.nl/ncdu [2] https://github.com/skywind3000/z.lua
rclone is a great utility for syncing data between local and remote (including remote to remote) locations and supports a ton of online services.
Well, rclone also supports an ncdu command modeled after the ncdu utility. It lets you quickly calculate directory sizes on remotes that don't show dir sizes, like Google Drive, for example.
This is a similar cognitive dissonance to when I first learned that "Visual Basic" and "Visual Studio" meant that the syntax of the displayed code was highlighted, not graphically represented in a non-lexical way.
Still though, these alternatives seem great for productivity locally, even if they’re not usable in a script.
fd .log$ -x mv {} {.}.bak
(Rename *.log to *.bak)
Can I do that with xargs, awk, and find? Yes, but every time I have to look up the man page to at least one of them and it’s enough friction that I might just open it in finder if it’s a handful of files.Having some of these utilities around is a crutch that let me leverage the entire ecosystem much more when I don’t have it. And when I do log into a shared enviroment and don’t have my crutch, then it’s easy to fill in the missing puzzle piece because it’s one part that’s missing and I’ve got the rest of the environment down.
Of course if all you do is shared environments I wouldn’t suggest these, but I would encourage people to use these to get more familiar with the CLI ecosystem.
find . -name '*.txt' -exec rename .log .bak {} \;
If your rename is prename by default you can use sed style replacement. Not to disagree with your overall point.a bit more generic, `for` loops and parameter expansion are good to know for proficiency, and also I dislike typing curly braces.
No need for xargs, awk or find
But what if I want to count the number of total files within each directory? Create tarballs out of each directory? Rename files that contain the word "FOOBAR" in them?
I can do this with fd and similar tools with slight modifications. With zmv I can rename files.
Well, I, for one, don't work "almost anywhere", I work with specific servers. I ain't gonna get a new server out of the blue. And if some teams works with the same N servers, they can mandate that the tools are present on all of them.
Plus even on some unknown system, one can quickly copy or download a set of static binaries as our toolset.
So unless someone is a sysadmin for heterogenous networks, or is called to go to random clients and fix unseen before systems, or some corporate mandate prevents them from having their tools installed, there's no reason not to expand beyond standard POSIX userland.
Aha, even on a machine with networking problems running a non-glibc set of libraries? (muslc has some problems running glibc (even static,) binaries OOTB, and most docker systems use alpine as a base which means... dealing with musl).
> So unless someone is a sysadmin for heterogenous networks, or is called to go to random clients and fix unseen before systems, or some corporate mandate prevents them from having their tools installed, there's no reason not to expand beyond standard POSIX userland.
I don't believe that the person in question was arguing against expanding beyond the POSIX userland -- rather that they were arguing for maintaining familiarity with POSIX tools in case you need to use them.
If you are in a small team of 5 or 6 people, with less than 100 servers to manage, sure, it's doable.
But if you are part of a very large team of 50 or more sysadmins, with a large infra in the thousands of nodes with various OSes and vintage of OSes (even if Unix only), things can get tricky quite quickly.
First a lot of people will want their favorite tools to be installed which can result in a huge mess of special toolboxes not being consistently installed (different path location, tool set varying from server to server).
Second, these tools, specially the shiny newer ones, need to be built, packaged and maintained properly which represent a significant load, specially across several OSes/Vintage of OSes.
Third, as a general rule, having an install base with as few packages as possible is generally a good thing, on one hand it reduces the surface of exposition of a server, on a second hand, it helps auditing for security vulnerabilities as "dead weight" dependencies (ex: libX11 for an editor which is both terminal based and graphical based, but only used in its terminal form on a server) will not trigger false positives in term of CVEs.
My point was more about education. I think becoming an expert in the standard tools should come before learning any custom ones, because it is a transferable skill.
A bit tedious, but you would still get to use your favourite tools.
pacman -Qq | xargs -r pacman -Qi | awk '
BEGIN { print "digraph deps {" }
/^Name/ { n = $3 }
/^Depends On/ {
for (i = 4; i <= NF; i++)
print " \"" n "\" -> \"" $i "\";"
}
END { print "}" }
' | dot -Tsvg > package-deps.svg- Can be distributed as a single binary, not requiring an interpreter and virtual environment. - Being more fun to make a hobby tool in due to minimal footguns compared to C/C++. - Really good dependency management and build tool making it easy to compose these CLIs out of powerful building blocks (at east for Rust). For example, ripgrep is broken up into a lot of packages that you can compose together to make your own custom tool.
That said, the idea that using cat to show a single file is "misusing" cat is prescriptivist rules-lawyering. There is no technical reason against using cat for non-concatenation purposes. The descriptivist interpretation of cat says using the tool for non-concatenation purposes is fine, since that's how people are actually using it.
However, note that cat is often misused as a substitute for STDIN redirection:
# this creates an extra process that wastes
# time copying STDIN to STDOUT
cat "${inputfile}" | do_stuff
# just connect inputfile directly to STDIN
do_stuff <"${inputfile}"
# or if you want to keep the input
# at the start of the pipeline
<"${inputfile}" do_stuffThere's also a commonly noted "unnecessary use of cat" where people do this:
cat file.txt | grep foo
instead of this: <file.txt grep.foo
but that's not relevant to bat (which can be used unnecessarily in the same way).For instance:
$ echo -e "\033]0;${USER} is an unfriendly person\007" > test-file.txt
Then, many days later: $ cat test-file.txt
will change your terminal title.With less, you _can_ interpret escape codes, but usually you don't, and I consider this the correct default.
What is clear is that
$ cat test-file.txt
does not print the initially-echoed text, but it is escaped and up to nefarious tasks. cless() {
pygmentize -O style=<style> "$1" 2>/dev/null | less
}
I have programs that depend on pygmentize so I am not sure I will use bat anytime soon when I already have pygmentize and less, or at least not for it having syntax highlighting.Edit: Sorry downvoter, thought I was being helpful - no-one mentioned the acronym yet. There's a lot online about it, more than I'm qualified to explain. Entertaining reading too. I remember reading about the UUOC Awards years ago..
ag: - silver searcher, fast parallelized recursive grep that can abide by things like `.gitignore`
fzf: - fuzzy finder
powerline-shell - $PS1 on steroids
Maybe rg is faster on more complex cases?
and skim is a rust clone of fzf
Here's a screenshot of my fish config: https://twitter.com/mxschumacher/status/1168993005744918528
A quick lookup suggests fish handles some of these differently than bash (apparently fish clears the buffer with this shortcut, so your scroll back is gone?).
There are a quite a few of these for anyone interested: https://kapeli.com/cheat_sheets/Bash_Shortcuts.docset/Conten...
alias ls "exa"
alias ll "exa -ll"
That way you get the nice shorter output which comes in handy for piping ls things like: ls -d | xargs ls
Lists the files in subdirectories.I’d like to know why Skim instead of FZF. They are pretty similar but I’ve been using the latter for years and would like to know of any possible advantages to it.