Get "PHP 8 in a Nuthshell" (Soon includes PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Better help pages for commands in the terminal

When you’re working with the terminal, you might have come across a situation where you don’t know how to use a particular command or what options it supports. In such cases, the best option that you have is to look at the help page of that command.

Traditional ways to get help

For most of the commands, you can get the help page by passing the --help option to the command. For instance, if you want to see the help page for the pwd command, you can do so by running the following command.

pwd --help

This will show a description of the pwd command along with the options it supports. But the problem with this is that the help page is usually very long and hard to parse. It’s just a wall of text.

The other way to get the help page is to use the man (short for manuals) command. For instance, if you want to see the help page for the pwd command, you can do so by running the following command.

man pwd

Similar to the --help option, this will also show a description of the pwd command along with the options it supports. The format is kind of similar to the --help option but it’s still not very user-friendly.

So, is there a better way to get the help pages for commands in the terminal? Yes, there is. It’s called tldr.

tldr to the rescue

tldr is a simplified and community-driven help page for commands. This is a part of the tldr-pages project which shows popular commands with practical examples so you don’t have to look at the long and boring blob of text.

The best thing about tldr is that it’s available for almost all platforms. The most common way to install tldr is via npm. You can install it by running the following command.

npm install -g tldr

In my case, I installed it using Homebrew on Ubuntu.

brew install tldr

Once installed, you can use tldr to get the help pages for commands. For instance, if you want to see the help page for the pwd command, you can do so by running the following command.

tldr pwd

Here’s how the help page for the pwd command looks like.

tldr pwd

As you can tell, the help page is much more user-friendly and nicely structured format. You get examples of that command along with a short description of what it does. Everything is color-coded. So, it makes it much easier to understand.

Here’s what man pwd looks like for comparison.

tldr pwd

Beyond the usual commands

tldr is not just limited to the usual commands. It also supports a wide range of commands including the development tools like git, npm, docker, etc. So, you can use tldr to get help pages for these commands as well.

For instance, if you want to see the help page for the docker command, you can do so by running the following command.

tldr docker

Here’s how the help page for the docker command looks like.

tldr docker

Or about Composer which is a dependency manager for PHP.

tldr composer

Here’s how the help page for the composer command looks like.

tldr composer

In closing

I think tldr is a great tool to have in your arsenal if you’re working with the terminal. It makes a great alternative to the traditional help pages and makes it much easier to understand the commands and their options. Give it a try and see if it fits your workflow.

Like this article?

Buy me a coffee

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?