Which command line tools do you use?

I’ve been watching Prag Dave’s Elixir course and I noticed he uses tree:

Tree is a recursive directory listing program that produces a depth indented listing of files. Color is supported ala dircolors if the LS_COLORS environment variable is set, output is to a tty, and the -C flag is used. With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories listed.

On Mac install with: brew install tree

EG:

$tree
.
├── README.md
├── lib
│   └── hangman.ex
├── mix.exs
└── mix.lock

You can use the options to ignore directories or files.

Any other cool command line tools you know of or use?

3 Likes

Corresponding tweet for this thread:

Share link for this tweet.

2 Likes

In short, a heck ton of them. I can write a series of articles about which tools I use. I made it a credo to gather as much as possible CLI and TUI tools and become master at them. The latter part still eludes me – not enough time and energy still – but I have become quite the small encyclopaedia of CLI/TUI tools.

Waiting for Aston’s “you should write a blog about it Dimi!”. :003:

7 Likes

You should definitely write about them!

I’m a hundred percent sure it will be a huge wealth of wisdom.

3 Likes

I like a tool called tl;dr.
It gives you basic knowledge of many commands.
On macOS it’s a good’ol brew install tldr
They also have a nodejs client, so it can be installed with npm.

EG:

❯ tldr grep

grep

Find patterns in files using regular expressions.
More information: <https://www.gnu.org/software/grep/manual/grep.html>.

- Search for a pattern within a file:
    grep "search_pattern" path/to/file

- Search for an exact string (disables regular expressions):
    grep --fixed-strings "exact_string" path/to/file

- Search for a pattern in all files recursively in a directory, showing line numbers of matches, ignoring binary files:
    grep --recursive --line-number --binary-files=without-match "search_pattern" path/to/directory

- Use extended regular expressions (supports `?`, `+`, `{}`, `()` and `|`), in case-insensitive mode:
    grep --extended-regexp --ignore-case "search_pattern" path/to/file

- Print 3 lines of context around, before, or after each match:
    grep --context|before-context|after-context=3 "search_pattern" path/to/file

- Print file name and line number for each match:
    grep --with-filename --line-number "search_pattern" path/to/file

- Search for lines matching a pattern, printing only the matched text:
    grep --only-matching "search_pattern" path/to/file

- Search stdin for lines that do not match a pattern:
    cat path/to/file | grep --invert-match "search_pattern"

If a command does not exist, you can add it with a PR on their repo.
It’s a community-based FOSS tool.

Saves me a ton of time in googling and reading man pages.

5 Likes

What he said!! ^^

Tldr looks great too - installed! :023:

2 Likes

I’m definitely one on the waiting list, bookmarked! :muscle:

4 Likes

Yeah, the amount of CLI/TUI tools are… immense and numerous, lol…

Let’s see, of non-posix-standard ones the two I use most often are rg (ripgrep) and jq (json query)` if someone wants a place to start.

5 Likes

Another one for tree, rg and jq.

Some others:

6 Likes
  • bat: I can completely vouch for it, it made my surfing in projects much much better. Had to open everything in Emacs before discovering it. And I am not quite at learning nvim just yet. Oh, and bonus for opening files in read-only mode (it’s a viewer after all). Spared me from accidentally edit things I shouldn’t.

  • fzf also changed my life. Hop in a directory, type bat , press Ctrl-T, pick what file to open by fuzzy-finding its name, press Enter twice, done. It’s going much further than that but that’s a matter for a bigger topic.

  • fd: a file finder, a much faster find. Automatically ignores most things that should be ignored in dev projects; if that’s not desired and you want to look through all files you just pass fd -HI and still find whatever you need. Called fd-find in various repos, Homebrew and some Linuxes included.

  • Recently got introduced to jless in HN. Absolutely amazing!

4 Likes

All of the above are awesome yes!

In addition, another I use more than I thought I would is broot, It’s a simple TUI to let you rather efficiently “explore directory trees and launch commands”, it has a surprising amount of functionality.

5 Likes

glab Gitlab CLI tool - GitHub - profclems/glab: The GitLab CLI tool. Archived: now officially adopted by GitLab as the official CLI tool and maintained at https://gitlab.com/gitlab-org/cli. See https://github.com/profclems/glab/issues/983

It’s not an official tool like GH’s. GH’s CLI is terrific and not being able to do the same with Gitlab was a shame. It’s patched!

3 Likes

I really like using the following tools:

vtop:

  • install → $ npm install -g vtop

Oh-My-Zsh with Spaceship Theme:

Github CLI:

wrk:

gcloud CLI:

grpcurl:

protoc:

fly or flyctl:

3 Likes
  • tree
  • man
  • curl
  • oh-my-zsh with modified robbyrussel theme which gives me Vim mode
  • Do asdf, git, node, npm, irb, go, iex, mix, psql etc count?

Edit: I forgot my most favorite tool, cal. It saves me from taking the cursor to the auto-hidden menu-bar to see the date. It shows me the whole calendar instead of just the date, with the current date highlighted. :slight_smile:

4 Likes

Thank you for the suggestion. This should be helpful. :slight_smile:

3 Likes

I reeeeeeaaaally like btop!

I also use httpie a lot.

3 Likes

Can you give us a link to that?

3 Likes

You probably have it installed already if you are on Linux or macOS.

5 Likes

cal (command) - Wikipedia.

If you are on Mac or Linux, it’s already there on your computer.

Running;
cal displays the current month,
cal -3 displays prev/current/next months
cal -j displays days of the year instead of days of the current month
cal -y displays the whole year
cal 2023 displays Calendar of 2023
cal 02 2023 displays Febraury 2023

4 Likes

Thank you and @Hallski, never heard of it lol. Pretty useful!

3 Likes