19 ms·
An Illustrated Guide to Useful Command Line Tools
- spoki0 7y agoWhat about yq, for parsing the increasing amount of yaml? Though there seems to be multiple competing tools by the same name... https://github.com/mikefarah/yq https://github.com/mikefarah/yq https://github.com/kislyuk/yq https://github.com/kislyuk/yq
- naikrovek 7y agoAmazing how many of those are written in Rust and Go.
- shabble 7y agounless I'm missing something, jq isn't[1] [1] https://github.com/stedolan/jq/tree/master/src https://github.com/stedolan/jq/tree/master/src
- NilsIRL 7y agoYeah that's an error
- degraafc 7y agoI don't think it says much about the tools themselves though, it just makes sense when you look at the author's GitHub and see a bunch of Rust projects.
- epage 7y agoI think there are a couple of relevant factors - 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.
- gameswithgo 7y agoCLI tools have pretty strong needs to be self contained exes that start up fast. That rules out a lot of the more popular languages.
- NilsIRL 7y agoThe reason for that is more the user than the tools themselves in my opinion.
- sys_64738 7y agoI found this too. I also found the only one I use is written in C - tig.
- wodenokoto 7y agoCan someone explain the misuse of cat, which bat solves?
- spoiler 7y agoI guess they just meant it as in "reading code," when in fact bat is better tool just for reading code.
- saagarjha 7y agoUsing cat to catenate a file to standard input isn't misuse, but it looks like bat performs syntax highlighting.
- deleted 7y ago[deleted]
- jhbadger 7y agoThey are referring to using cat to print out a file to the terminal. I'm not sure that's a "misuse", but personally I've never done it, using "more" or "less" instead. "bat" really is a replacement for more/less, only with additional features such as syntax highlighting in source code.
- johnisgood 7y agoI use: 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.
- pcr910303 7y agoThat use is the exact reason why LESSPIPE exists, check out man less & https://www-zeuthen.desy.de/~friebel/unix/lesspipe.html https://www-zeuthen.desy.de/~friebel/unix/lesspipe.html
- tambourine_man 7y agoLots of cool stuff in here. I’m going to have a long look at Restic and Syncthing. 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.
- floatboth 7y agoThere's a lot of these pickers and they are indeed similar. I've been using https://github.com/jhawthorn/fzy https://github.com/jhawthorn/fzy since it's not fullscreen and has a really good matching algorithm.
- apjana 7y agofzy is cool and probably underrated. It's the preferred fuzzy utility for file manager nnn too.
- cjbassi 7y agoI've tried both Skim and fzf, and in my experience fzf has a much better fuzzy matching algorithm so that's what I'd recommend using. Plus it supports true color configuration fwiw.
- mackrevinack 7y agoi loooove syncthing. something i set up recently is a folder called .home_sync to sync my dotfiles between computers. I have a bash script that sets up the symlinks and then version control turned on for the syncthing folder so i can have a record of any changes if I need to revert something
- nidble 7y agoI have a similar setup with Syncthing and a ~/.dotfiles directory, but I recommend GNU Stow to manage symlinking. Simple, ubiquitous and very useful.
- aquova 7y agoA number of the utilities mentioned here (bat, fd, hexyl) are made by the same author, who makes a number of additional command line utilities in Rust. They're all rather easy to use and aesthetically pleasing, I'm a fan of their work: https://github.com/sharkdp https://github.com/sharkdp
- abathur 7y agoIndeed! I'm a fan of hyperfine and bat, and I've been meaning to check out pastel when I have more time...
- 29athrowaway 7y agoThis man is also creating awesome tools: https://github.com/BurntSushi https://github.com/BurntSushi
- mxschumacher 7y agoin order to avoid having to unlearn commands like cat and ls, I use aliases to invoke bat and exa. Here's a screenshot of my fish config: https://twitter.com/mxschumacher/status/1168993005744918528 https://twitter.com/mxschumacher/status/1168993005744918528
- dickeytk 7y agoI would do 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.
- mxschumacher 7y agogood idea - thank you!
- WonkeyMonkey 7y agoFor clearing the screen, try 'Ctrl-l' (lowercase L) 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/Contents/Resources/Documents/index https://kapeli.com/cheat_sheets/Bash_Shortcuts.docset/Conten...
- aquova 7y agoI quite like this list, there are a number of utilities here that I already use on a daily basis. There are also a few utilities that I like that weren't on this list, or some alternatives to what was shown. Some off the top of my head: - 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 https://github.com/jarun/nnn [1] https://dev.yorhel.nl/ncdu https://dev.yorhel.nl/ncdu [2] https://github.com/skywind3000/z.lua https://github.com/skywind3000/z.lua
- cauthon 7y agoSeconding ncdu! The interface is great, and I like that it’s modular so you can run the disk usage component as a cronjob and then have a nightly snapshot readily accessible
- rovr138 7y agoAnd regarding ncdu, there are static binaries for Linux. Just put them in a folder and use them.
- wodny 7y agoNice. I've missed the static binaries on the homepage and should have tried static compilation myself. Now my little python2 and find-based scripts exporting ncdu-compatible outputs[1] on systems without ncdu seem a bit redundant. On the other hand, there are some examples of filtering the output with jq. [1]: https://github.com/wodny/ncdu-export https://github.com/wodny/ncdu-export
- apjana 7y ago+1 for nnn!
- archon810 7y agoI'd like to further expand on the topic of ncdu. 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. https://rclone.org/ https://rclone.org/ https://rclone.org/commands/rclone_ncdu/ https://rclone.org/commands/rclone_ncdu/
- floatboth 7y agoI would add https://github.com/drbig/snb https://github.com/drbig/snb https://github.com/dandavison/delta https://github.com/dandavison/delta https://github.com/MitMaro/git-interactive-rebase-tool https://github.com/MitMaro/git-interactive-rebase-tool
- atonalfreerider 7y agoAn observation: I have always taken the meaning of the word "illustrated" to specifically refer to non-lexical graphics. Searching the dictionary definition of the word, I find a looser definition that applies to "examples" intended to aid an explanation. 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.
- mysterydip 7y agoI believe Visual Basic/Studio referred tonthe addition of WYSIWYG GUI creation tools and event binding to the languages.
- Sharlin 7y agoI’ve always assumed that the ”Visual” in VB and others refers to the WYSIWYG drag’n’drop interface for creating GUIs.
- claudiawerner 7y agoThe guide mentions a dotfile manager, but here's something I found[0] on HN a while ago that's really cool: just make your home folder a git repository. [0] https://news.ycombinator.com/item?id=11071754 https://news.ycombinator.com/item?id=11071754
- sbr464 7y agoNice post! Surprised to not see httpie mentioned.
- enriquto 7y agoreally bad name for "dot", it has always been the graphviz interface
- jolmg 7y agoIndeed, and graphviz's dot is really useful, too. It makes it really easy to make all sorts of graphs. For example, if I wanted to make a dependency graph of all the packages I have installed in Archlinux, I can use it like this: 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
- deleted 7y ago[deleted]
- matthewaveryusa 7y agoI always find exotic command-line tools cool but they never stick because Im constantly sshing/using/targeting a variety of systems I don't own that don't have them readily istalled
- k_sze 7y agoIf you have access to the build tools, you can compile and install stuff in your home directory. A bit tedious, but you would still get to use your favourite tools.
- dickeytk 7y agoEncryptable, portable home directories is one of the goals of systemd. I can’t wait until one day when I just ssh in and it’s all there
- fnord77 7y agoNo mention of things that have gained a lot of traction, like `ag` and `fzf` ag: - silver searcher, fast parallelized recursive grep that can abide by things like `.gitignore` fzf: - fuzzy finder powerline-shell - $PS1 on steroids
- grosswait 7y agoI find the to be faster than ag personally
- fnord77 7y agoOn a simple case, `time rg ^:debug ~/projects`, `ag` appears to be about 10% faster for me, which is negligible for most cases anyway. Maybe rg is faster on more complex cases?
- burntsushi 7y agoCan you reproduce it in a public corpus and file a bug report? ripgrep should never be slower than ag.
- epage 7y agoIt does mention rg which is in the same category as ag and, maybe this is my own bias, seems to have more mindshare now.
- ibly31 7y agoAgreed - I used to use Ag but switched to Ripgrep. Better in every single way, in my opinion. It's obscenely fast and has good defaults
- Graziano_M 7y agoripgrep >> ag and skim is a rust clone of fzf
- leshow 7y agoAs much as I do use a number of these tools, there's something to be said for being able to use any box you ssh or log into that has the default tools available on any *nix system. ls, cat, find, etc. I'm hypocritical a bit in that I do use rg, and fd, but I just can't bring myself to deviate too far from the 'default'.
- dblotsky 7y agoI often use the term “standard” in place of “default” there.
- dblotsky 7y agoI’m gonna sound like an old person here. As much as these tools are gorgeous and ergonomic, remember that the others are standard, which means they’re available (almost) everywhere. Still though, these alternatives seem great for productivity locally, even if they’re not usable in a script.
- dickeytk 7y agoI’ve actually found myself using these to get me much more proficient in the Shell overall. fd in particular is so much easier to use I find myself doing things like: 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.
- rhizome 7y agobash/zsh: for f in *.log; do mv "$f" "${f/%log/bak}"; done a bit more generic, `for` loops and parameter expansion are good to know for proficiency, and also I dislike typing curly braces.
- mahesh_rm 7y agoAn alternative to z, which I find a little bit "smarter" is autojump.
- madengr 7y agoWhat’s the terminal prompt shown the graphics?
- the_greyd 7y agoMy code editor does a fair job of finding things for me, I know I won't use ripgrep/fzf that often :shrug: On the other hand I would recommend fish shell (replacement for bash) with z plugin and http (replacement for curl).