10 modern Terminal/CLI tools that will change your terminal experience

10 modern Terminal/CLI tools that will change your terminal experience

One of the main advantages of using a MacBook is that it is based on the UNIX operating system. This means that it offers a wide range of customization options for power users who are familiar with the terminal and know how to use it effectively.

Although macOS has a user-friendly interface and hides much of the complexity behind glossy settings panels, the customization possibilities are still wide for those who know how to access them.

As a developer who spends a lot of time in the terminal, I have been able to create an ergonomic terminal experience thanks to modern tools and commands that replace or encapsulate traditional programs like cat, curl, and find. After sharing these tools with my Gs, we decided to write a curated list to share with others.

Modern replacements :)

This tools are meant to replace existing common commands, sometimes as a drop in that requires just an alias in your dotfile.

  1. fd – fd is a fast, user-friendly alternative/replacement to the find command that allows you to search for files and directories based on their name, type, and other attributes.

  2. The Silver Searcher, also known as ag, is a fast, feature-rich alternative to the grep command for searching files and directories. It allows you to search for patterns in files and directories based on various criteria, such as file type, case sensitivity, and more. To install ag, you can use the package manager of your choice, such as apt-get, yum, or brew.

    Here are a few examples of how you can use ag to search for patterns in your files and directories:

    • To search for a specific pattern in all files in the current directory and its subdirectories, you can use the following command:
    ag pattern

This will display a list of the files that contain the specified pattern, along with the lines in those files where the pattern appears.

  • To search for a pattern in a specific file type, such as .txt or .py, you can use the --type flag:
    ag --type=py pattern

This will search for the pattern in all .py files in the current directory and its subdirectories.

  • To search for a pattern in a specific directory, you can use the --path flag:
    ag --path=path/to/directory pattern

This will search for the pattern in the specified directory and its subdirectories.

These are just a few examples of how you can use ag to search for patterns in your files and directories. For a complete list of options and usage examples, you can refer to the ag documentation.

  1. zoxide and fzf is a fast, feature-rich alternative to the cd command for navigating the filesystem. It allows you to quickly and easily jump to directories based on their names or paths. To install zoxide, you can use the package manager of your choice, such as apt-get, yum, or brew.

    Once zoxide is installed, you can use the zoxide add command to add directories to your list of "favorites":

     zoxide add /path/to/favorite/directory
    

    Then, you can use the z command to quickly jump to a favorite directory:

     z favorite
    

    fzf is a command-line fuzzy finder that allows you to quickly search and filter lists of items, such as files and directories. It can be used in combination with zoxide to easily search and jump to favorite directories. To install fzf, you can use the package manager of your choice, such as apt-get, yum, or brew.

    To use fzf with zoxide, you can use the zf command:

     zf
    

    This will open the fzf interface, which allows you to search and filter your favorite directories and select one to jump to.

    These are just a few examples of how you can use zoxide and fzf to navigate the filesystem quickly and easily from the command line. For more information and usage examples, you can refer to the zoxide and fzf documentation.

  2. jq – jq is a command-line JSON processor that allows you to parse and manipulate JSON data from the command line. It is particularly useful for working with APIs and other data sources that return JSON.

Example:

curl https://api.github.com/users/byolabisi | jq .id

This command will retrieve the user information for the GitHub user "byolabisi" and display their user ID using jq.

You can also use jq to transform JSON data by using filters and functions. For example, you can use the map() function to apply a transformation to each element in an array:

# Extract the values of the "id" and "name" keys from each object in the "items" arraycat file.json | jq '.items | map({id, name})'

You can also use jq to filter data by using a condition in the select() function. For example, you can use the following command to extract only the objects in the "items" array that have a "name" key with a value of "foo":

# Extract objects in the "items" array with a "name" key of "foo" cat file.json | jq '.items | map(select(.name == "foo"))'
  1. bat – bat is a cat clone with syntax highlighting and other enhancements. It can be used to view the contents of files in a more readable and visually appealing way.

Example:

bat file.txt

This command will display the contents of the file "file.txt" using bat.

You can also use the --pager option to view the file using a pager, such as less:

$ bat --pager file.txt

This will allow you to navigate the file using the arrow keys, page up and down, and other pager commands.

In addition to viewing files, bat also supports a number of other options and features, such as searching and highlighting, line numbering, and more. You can view the full list of options by running bat --help.

Overall, bat is a useful tool for viewing and interacting with files in the terminal. Its syntax highlighting, formatting options, and other features make it a valuable addition to any terminal toolkit.

  1. exa – exa is a modern replacement for the ls command that offers a number of enhancements, such as color-coded file types, extended attributes, and human-readable file sizes.

Example:

exa -la

This command will list the contents of the current directory in long format, using exa.

You can also use various options and flags to customize the output of exa. For example, you can use the --long flag to display additional information about each file, such as the size, permissions, and last modified date:

exa --long

You can also use the --sort flag to sort the output by a specific field, such as the size or modification date:

exa --long --sort=size

Or you can use the --tree flag to display the directory tree structure:

exa --tree

These are just a few examples of the many options and flags available with exa. For a complete list of options and usage examples, you can refer to the exa documentation.

  1. Ripgrep (rg) is a fast, powerful grep tool that allows you to search for patterns in files and directories. It is faster and more feature-rich than the grep command and supports regex, Unicode, and more. Here is an example of using rg to search for a pattern in a directory of files:

     rg "pattern" /path/to/directory
    

    This will search for the pattern "pattern" in all files in the specified directory.

    You can also use rg to search for patterns in specific file types, by specifying the file type with the --type flag. For example, to search for the pattern "pattern" in all .txt files in a directory:

     rg --type=txt "pattern" /path/to/directory
    

    You can also use the -i flag to perform a case-insensitive search, or the -w flag to only match whole words. For example, to search for the pattern "pattern" in all .txt files in a directory, ignoring case:

     rg -i --type=txt "pattern" /path/to/directory
    

    There are many more options and features available with rg. For a full list of options and usage examples, you can consult the rg documentation.

  2. lsd is a command-line utility that displays a directory listing in a colorful, easy-to-read format. It is an alternative to the ls command and offers improved formatting, better readability, and a range of customization options.

    To use lsd, you simply need to specify the directory you want to list as an argument:

     lsd /path/to/directory
    

    You can also use options to customize the output. For example, you can use the -l option to display detailed information about each file, including the size, permissions, and modification date:

     lsd -l /path/to/directory
    

    You can also use the --sort option to specify how the files should be sorted. For example, you can use --sort=size to sort the files by size:

     lsd --sort=size /path/to/directory
    

    There are many other options available, including options to hide dotfiles, display hidden files, and more. You can see a full list of options by running lsd --help.

    In conclusion, lsd is a useful command-line tool for displaying directory listings in a more readable and visually appealing format. It offers a range of customization options and can be a useful alternative to the ls command.

    TUI (text-based user interface) tools

TUI (text-based user interface) tools are command-line programs that provide a text-based interface for interacting with a computer. These tools can be useful for performing a wide range of tasks, such as managing files and directories, navigating the filesystem, and more. Here are a few examples of TUI tools and how to use them:

  1. nano: Nano is a simple text editor that can be used to edit text files from the command line.

    To open a file in Nano, you can use the following command:

nano filename.txt

This will open the file filename.txt in the Nano editor. To save your changes and exit Nano, you can use the Ctrl + Xkeyboard shortcut.

  • To edit an existing file in Nano, you can use the following command:
nano existingfile.txt

This will open the existingfile.txt file in the Nano editor.

  • To save your changes and exit Nano, you can use the Ctrl + X keyboard shortcut. You will be prompted to confirm that you want to save the changes before exiting the editor.

These are the basic steps for using Nano to create and edit text files from the command line. Nano also offers a number of other features and options, such as search and replace, syntax highlighting, and more. For a complete list of features and usage examples, you can refer to the nano documentation.

  1. htop – htop is an interactive process viewer that allows you to view and manage processes on your system in real-time. It offers a number of features, such as the ability to kill processes, change their priority, and view resource usage.
  • To use the htop terminal tool, you will first need to install it on your system. You can use the package manager of your choice, such as apt-get, yum, or brew, to install htop. For example, on a Debian-based system, you can use the following command to install htop:
sudo apt-get install htop

Once htop is installed, you can use the htop command to launch it. When you first run htop, you will see a screen similar to the following:

PID  USER PRI NI VIRT RES SHR S CPU% MEM%  TIME+ Command 5639  user  20  0  10.5M  2.3M 1.8M S  0.00.2  0:00.08 htop

The htop screen shows a list of processes running on your system, along with information about each process, such as the process ID, user, CPU usage, and memory usage. You can use the arrow keys to navigate up and down the list, and you can use the F5 key to switch to a tree view that shows the relationships between processes.

You can use the htop interface to manage processes on your system. For example, you can use the F9 key to bring up a menu that allows you to kill a process, renice a process (change its priority), or send a signal to a process. You can also use the / key to search for a process by name, and you can use the s key to sort the process list by a variety of criteria.

In conclusion, all these tools is are powerful and user-friendly tools for managing processes on your system. For a complete list of features and usage examples, you can refer to their respective documentations.

Voila!