DEV Community

loading...
Cover image for 15 Command Line Tools which Spark Joy in Your Terminal

15 Command Line Tools which Spark Joy in Your Terminal

Jean-Michel Fayard ๐Ÿ‡ซ๐Ÿ‡ท๐Ÿ‡ฉ๐Ÿ‡ช๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ธ๐Ÿ‡จ๐Ÿ‡ด
Weeks of programming can save hours of planning
Originally published at jmfayard.dev ใƒปUpdated on ใƒป4 min read

Put joy and productivity inside your Terminal with those cool command line tools.

But before we start, let's cover how you can install and uninstall them.

Table of contents

Quick install

I don't know about you, but I don't enjoy spending lots of time installing stuff.

So here is my executive summary

PROGRAMS="hub httpie ripgrep bat fzf fd fd-find jq autojump direnv tig tmux neovim exa just lazygit jump"
NPM="how-2 tldr"
export INSTALLER="sudo apt-get"    # on Debian/Ubuntu
export INSTALLER="something else"  # on another Linux
export INSTALLER="brew"            # on macOS
for program in $PROGRAMS ; do $INSTALLER install $program ; done
for program in $NPM ; do npm install -g $program ; done
Enter fullscreen mode Exit fullscreen mode

You may want to configure your .profile

## Put in .bash_profile or .zshrc
alias ls=exa
alias cat=bat
Enter fullscreen mode Exit fullscreen mode

Try, adopt or uninstall

Try out the CLI tools. If you don't like them, uninstall them the same way

PROGRAMS="neovim exa"
export INSTALLER="brew"            # on macOS
for program in $PROGRAMS ; do $INSTALLER uninstall $program ; done
Enter fullscreen mode Exit fullscreen mode

This being done, let's move on to the tools!

The 15 Command Line Tools which Spark Joy in Your Terminal

*tldr-pages/tldr: ๐Ÿ“š Collaborative cheatsheets for console commands

A must have

The man page is too long, didn't read.

Replace $ man git-checkout by $ tldr git-checkout

You will find what you need in 5s or less, 80% of the time or more

GitHub logo tldr-pages / tldr

๐Ÿ“š Collaborative cheatsheets for console commands

tldr-pages

Build status Gitter chat Merged PRs GitHub contributors license

What is tldr-pages?

The tldr-pages project is a collection of community-maintained help pages for command-line tools, that aims to be a simpler, more approachable complement to traditional man pages.

Maybe you are new to the command-line world? Or just a little rusty Or perhaps you can't always remember the arguments to lsof, or tar?

It certainly doesn't help that the first option explained in man tar is:

-b blocksize
   Specify the block size, in 512-byte records, for tape drive I/O
   As a rule, this argument is only needed when reading from or writing to tape drives
   and usually not even then as the default block size of 20 records (10240 bytes) is very common.

There seems to be room for simpler help pages, focused on practical examples. How about:

animated svg of the tldr client displaying the tar command

This repository is just that: an ever-growing collection of examples for the most common UNIX, Linux, macOS, SunOSโ€ฆ

stedolan/jq: Command-line JSON processor

Unix scripts are based on the idea that you have a stdout with lines of outputs.

How do you autoamte things if you have JSON instead? (and JSON is everywhere)

jq is the answer

GitHub logo stedolan / jq

Command-line JSON processor

jq

jq is a lightweight and flexible command-line JSON processor.

Coverage Status Unix: Build Status Windows: Windows build status

If you want to learn to use jq, read the documentation at https://stedolan.github.io/jq. This documentation is generated from the docs/ folder of this repository You can also try it online at jqplay.org.

If you want to hack on jq, feel free, but be warned that its internals are not well-documented at the moment. Bring a hard hat and a shovel. Also, read the wiki: https://github.com/stedolan/jq/wiki, where you will find cookbooks, discussion of advanced topics, internals, release engineering, and more.

Source tarball and built executable releases can be found on the homepage and on the github release page, https://github.com/stedolan/jq/releases

If you're building directly from the latest git, you'll need flex bison (3.0 or newer), libtool, make, automake, and autoconf installed. To get regexp support you'll also need to install Oniguruma or clone it asโ€ฆ

direnv/direnv: unclutter your .profile

My .profile is horrible so I'm looking forward to try this one

GitHub logo direnv / direnv

unclutter your .profile

direnv -- unclutter your .profile

Built with Nix Packaging status latest packaged version(s)

direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.

Use cases

  • Load 12factor apps environment variables
  • Create per-project isolated development environments
  • Load secrets for deployment

How it works

Before each prompt, direnv checks for the existence of a .envrc file in the current and parent directories. If the file exists (and is authorized), it is loaded into a bash sub-shell and all exported variables are then captured by direnv and then made available to the current shell.

It supports hooks for all the common shells like bash, zsh, tcsh and fish This allows project-specific environment variables without cluttering the ~/.profile file.

Because direnv is compiled into a single static executable, it is fast enough to be unnoticeable on each prompt. It is also language-agnostic and can beโ€ฆ

jonas/tig: Text-mode interface for git

GitHub logo jonas / tig

Text-mode interface for git

Tig: text-mode interface for Git

Linux CI macOS CI AppVeyor Build Join Chat

What is Tig?

Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, but can also assist in staging changes for commit at chunk level and act as a pager for output from various Git commands.

Bugs and Feature Requests

Bugs and feature requests can be reported using the issue tracker or by mail to either the Git mailing list or directly to the maintainer. Ensure that the word "tig" is in the subject. For other Tig related questions please use Stack Overflow: https://stackoverflow.com/questions/tagged/tig.

Installation and News

Information on how to build and install Tig are found in the installation instructions.

News about releases and latest features and bug fixes are found in the release notes.




tmux/tmux: terminal multiplexer

tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

GitHub logo tmux / tmux

tmux source code

Welcome to tmux!

tmux is a terminal multiplexer: it enables a number of terminals to be created accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris.

Dependencies

tmux depends on libevent 2.x, available from this page.

It also depends on ncurses, available from this page.

To build tmux, a C compiler (for example gcc or clang), make, pkg-config and a suitable yacc (yacc or bison) are needed.

Installation

Binary packages

Some platforms provide binary packages for tmux, although these are sometimes out of date. Examples are listed on this page.

From release tarball

To build and install tmux from a release tarball, use:

./configure && make
sudo make install
Enter fullscreen mode Exit fullscreen mode

tmux can use the utempter library to update utmp(5), if itโ€ฆ

santinic/how2: stackoverflow from the terminal

StackOverflow being such a massive part of a developer workflow, why not automating it?

GitHub logo santinic / how2

stackoverflow from the terminal

how2: stackoverflow from the terminal

NPM Version

how2 finds the simplest way to do something in a unix shell It's like man, but you can query it in natural language:

Demo of using how2

Install

You can install it via npm:

npm install -g how-2

if it gives you EACCES errors, you need to fix npm permissions. Or you can just use sudo npm install -g how-2 if you don't care.

Usage

If you don't specify a language it defaults to Bash unix command line how2 tries to give you immediately the most likely answer:

how2 unzip bz2

After that you can press SPACE to go to the interactive mode, where you can choose a different stackoverflow question/answer.

how2 interactive mode

how2 interactive mode 2

You can use -l lang to find answers for other languages:

-l python

Copy-Paste with mouse

When you are in "interactive mode" (after you press SPACE), if you want to copy-paste more than one line you can use block-select:

With Ubuntuโ€ฆ

BurntSushi/ripgrep : like grep, but better

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

GitHub logo BurntSushi / ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

ripgrep (rg)

ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern. By default, ripgrep will respect your .gitignore and automatically skip hidden files/directories and binary files. ripgrep has first class support on Windows, macOS and Linux, with binary downloads available for every release ripgrep is similar to other popular search tools like The Silver Searcher, ack and grep.

Build status Crates.io Packaging status

Dual-licensed under MIT or the UNLICENSE.

CHANGELOG

Please see the CHANGELOG for a release history.

Documentation quick links

Screenshot of search results

A screenshot of a sample search with ripgrep

Quick examples comparing tools

This example searches the entire Linux kernel source tree (after running make defconfig && make -j8) for [A-Z]+_SUSPEND, where all matches must be words. Timings were collected on a system with an Intel i7-6900K 3.2 GHz.

Please remember that a singleโ€ฆ

sharkdp/bat: A cat(1) clone with wings.

Syntax highlighting for a large number of programming and markup languages, because why not?

You can alias it

$ alias cat=bat

GitHub logo sharkdp / bat

A cat(1) clone with wings.

bat - a cat clone with wings
Build Status license Version info
A cat(1) clone with syntax highlighting and Git integration

Key Features โ€ข How To Use โ€ข Installation โ€ข Customization โ€ข Project goals, alternatives
[ไธญๆ–‡] [ๆ—ฅๆœฌ่ชž] [ํ•œ๊ตญ์–ด] [ะ ัƒััะบะธะน]

Syntax highlighting

bat supports syntax highlighting for a large number of programming and markup languages:

Syntax highlighting example

Git integration

bat communicates with git to show modifications with respect to the index (see left side bar):

Git integration example

Show non-printable characters

You can use the -A/--show-all option to show and highlight non-printable characters:

Non-printable character example

Automatic paging

By default, bat pipes its own output to a pager (e.g less) if the output is too large for one screen If you would rather bat work like cat all the time (never page output), you can set --paging=never as an option, either on the command line or in your configuration file If you intend to alias cat to bat in yourโ€ฆ

junegunn/fzf: A command-line fuzzy finder

Makes looking for a file as easy as in Visutal Studio Code or IntelliJ

GitHub logo junegunn / fzf

๐ŸŒธ A command-line fuzzy finder

fzf - a command-line fuzzy finder github-actions

fzf is a general-purpose command-line fuzzy finder.

It's an interactive Unix filter for command-line that can be used with any list; files, command history, processes, hostnames, bookmarks, git commits etc.

Pros

  • Portable, no dependencies
  • Blazingly fast
  • The most comprehensive feature set
  • Flexible layout
  • Batteries included
    • Vim/Neovim plugin, key bindings, and fuzzy auto-completion

Table of Contents

sharkdp/fd: like find, but better

A simple, fast and user-friendly alternative to 'find'

GitHub logo sharkdp / fd

A simple, fast and user-friendly alternative to 'find'

fd

Build Status Build status Version info [ไธญๆ–‡] [ํ•œ๊ตญ์–ด]

fd is a program to find entries in your filesytem It is a simple, fast and user-friendly alternative to find While it does not aim to support all of find's powerful functionality, it provides sensible (opinionated) defaults for a majority of use cases.

Quick links:

Features

  • Intuitive syntax: fd PATTERN instead of find -iname '*PATTERN*'.
  • Regular expression (default) and glob-based patterns.
  • Very fast due to parallelized directory traversal.
  • Uses colors to highlight different file types (same as ls).
  • Supports parallel command execution
  • Smart case: the search is case-insensitive by default. It switches to case-sensitive if the pattern contains an uppercase character*.
  • Ignores hidden directories and files, by default.
  • Ignores patterns from your .gitignore, by default.
  • The command name is 50% shorter* than find :-).

Demo

Demo

How to use

First, toโ€ฆ

wting/autojump

A cd command that learns - easily navigate directories from the command line

GitHub logo wting / autojump

A cd command that learns - easily navigate directories from the command line

NAME

autojump - a faster way to navigate your filesystem

DESCRIPTION

autojump is a faster way to navigate your filesystem. It works by maintaining a database of the directories you use the most from the command line.

Directories must be visited first before they can be jumped to.

USAGE

j is a convenience wrapper function around autojump. Any option that can be used with autojump can be used with j and vice versa.

  • Jump To A Directory That Contains foo:

    j foo
    
  • Jump To A Child Directory:

    Sometimes it's convenient to jump to a child directory (sub-directory of current directory) rather than typing out the full name.

    jc bar
    
  • Open File Manager To Directories (instead of jumping):

    Instead of jumping to a directory, you can open a file explorer window (Mac Finder, Windows Explorer, GNOME Nautilus, etc.) to the directory instead.

    jo music
    

    Opening a file manager toโ€ฆ

inconshreveable/ngrok: Introspected tunnels to localhost

You have your web app working on localhost, the CI is broken and you can't share your work with your colleagues.

Except that with ngrok, you can!

GitHub logo inconshreveable / ngrok

Introspected tunnels to localhost

Build status

ngrok - Introspected tunnels to localhost (homepage)

โ€I want to expose a local server behind a NAT or firewall to the internet.โ€

What is ngrok?

ngrok is a reverse proxy that creates a secure tunnel from a public endpoint to a locally running web service ngrok captures and analyzes all traffic over the tunnel for later inspection and replay.

ngrok 2.x

ngrok 2.x is the successor to 1.x and the focus of all current development effort. Its source code is not available.

NOTE This repository contains the code for ngrok 1.x.

Status of the ngrok 1.x project

ngrok 1.x is no longer developed, supported or maintained by its author, except to ensure that the project continues to compile. The contribution policy has the following guidelines:

  1. All issues against this repository will be closed unless they demonstrate a crash or other complete failure of ngrok's functionality.
  2. All issues againstโ€ฆ

github/hub:

A command-line tool that makes git easier to use with GitHub.

GitHub logo github / hub

A command-line tool that makes git easier to use with GitHub.

hub is a command line tool that wraps git in order to extend it with extra features and commands that make working with GitHub easier.

For an official, potentially more user-friendly command-line interface to GitHub see cli.github.com and this comparison.

This repository and its issue tracker is not for reporting problems with GitHub.com web interface. If you have a problem with GitHub itself, please contact Support.

Usage

$ hub clone rtomayko/tilt
#=> git clone git://github.com/rtomayko/tilt.git
# if you prefer HTTPS to git/SSH protocols:
$ git config --global hub.protocol https
$ hub clone rtomayko/tilt
#=> git clone https://github.com/rtomayko/tilt.git
Enter fullscreen mode Exit fullscreen mode

See usage examples or the full reference documentation to see all available commands and flags.

hub can also be used to make shell scripts that directly interact with the GitHub API.

hub can be safely aliased as git, so you can type $ git <command> in theโ€ฆ

Build your own CLI tools, but maybe not in Bash

Command-line tools are great to automate and simplify your developer workflow.

Tools written by others are good, but why would you not write your own tools?

I have a strong opinion weakly held on this topic:

After 15 years of trying to program in Bash and being stuck at trials and errors, I think it's time to retire Bash.

Why not using your favorite programming language instead?

I found they are 10x time better than Bash.

Python, Go and JavaScript are all good choices to write a CLI tool.

Now my favorite language being Kotlin, I wanted to write a starter project for my own CLI tools using Kotlin multiplatform.

So if you allow me this shameless plug, have a look at the kotlin-cli-starter GitHub template

GitHub logo jmfayard / kotlin-cli-starter

Life is too short for Bash programming

A starter project to build command-line tools in Kotlin Multiplatform

Contains a re-implementation of a real world CLI tool: git-standup

jmfayard_kotlin-cli-starter__Life_is_too_short_for_Bash_programming_and_Telegram_and_GitHub_Desktop

Installation

You can install using one of the options listed below

Source Command
curl curl -L https://raw.githubusercontent.com/jmfayard/kotlin-cli-starter/main/installer.sh | sudo sh
Kotlin Native Clone, run ./gradlew install then $ git standup
Kotlin JVM Clone and run ./gradlew run
Tests ./gradlew allTests

Why?

Being able to write your own command-line tools is a great skill to have. Automate all the things!

You can write the CLI tools in Kotlin and reap the benefits of using

  • a modern programming language
  • modern IDE support
  • modern practices such as unit testing and continuous integration
  • leverage Kotlin multiplatform libraries
  • run your code on the JVM and benefit from a wealth of Java libraries
  • or build a native executable, which starts very fast and can be deployed on a computer without the JVM

My strong opinion -โ€ฆ

Any cool tool that I'm missing?

No such list would be ever complete, so please add your recommandation in the comments.

Updates from my readers

jesseduffield/lazygit simple terminal UI for git commands

lazygit is a very cool git client

GitHub logo jesseduffield / lazygit

simple terminal UI for git commands

CI Go Report Card GolangCI GoDoc GitHub tag TODOs

A simple terminal UI for git commands, written in Go with the gocui library.

Rant time: You've heard it before, git is powerful, but what good is that power when everything is so damn hard to do? Interactive rebasing requires you to edit a goddamn TODO file in your editor? Are you kidding me? To stage part of a file you need to use a command line program to step through each hunk and if a hunk can't be split down any further but contains code you don't want to stage, you have to edit an arcane patch file by hand? Are you KIDDING me?! Sometimes you get asked to stash your changes when switching branches only to realise that after you switch and unstash that there weren't even any conflicts and it would have been fine to just checkout the branch directly? YOU HAVE GOT TO BEโ€ฆ




See the demo

casey/just: ๐Ÿค– Just a command runner

Inspired by make

GitHub logo casey / just

๐Ÿค– Just a command runner

just

crates.io version build status downloads chat on discord say thanks

just is a handy way to save and run project-specific commands.

(้žๅฎ˜ๆ–นไธญๆ–‡ๆ–‡ๆกฃ,่ฟ™้‡Œ,ๅฟซ็œ‹่ฟ‡ๆฅ!)

Commands, called recipes, are stored in a file called justfile with syntax inspired by make:

build
    cc *.c -o main
# test everything
test-all: build
    ./test --all
# run a specific test
test TEST: build
    ./test --test {{TEST}}
Enter fullscreen mode Exit fullscreen mode

You can then run them with just RECIPE:

$ just test-all
cc *.c -o main
./test --all
Yay, all your tests passed!
Enter fullscreen mode Exit fullscreen mode

Just has a ton of useful features, and many improvements over Make:

  • Just is a command runner, not a build system, so it avoids much of Makeโ€™s complexity and idiosyncrasies. No need for .PHONY recipes!

  • Linux, MacOS, and Windows are supported with no additional dependencies. (Although if your system doesnโ€™t have an sh, youโ€™ll need to choose a different shell.)

  • Errors are specific and informativeโ€ฆ

gsamokovarov/jump: Jump helps you navigate faster by learning your habits. โœŒ๏ธ

An alternative to cd that feels like it can read your mind

GitHub logo gsamokovarov / jump

Jump helps you navigate faster by learning your habits. โœŒ๏ธ

[releases]

Build Status Go Report Card

Jump integrates with your shell and learns about your navigational habits by keeping track of the directories you visit. It gives you the most visited directory for the shortest search term you type.

Demo

Installation

Jump comes in packages for the following platforms.

Platform Command
macOS brew install jump
Ubuntu wget https://github.com/gsamokovarov/jump/releases/download/v0.40.0/jump_0.40.0_amd64.deb && sudo dpkg -i jump_0.40.0_amd64.deb
Fedora wget https://github.com/gsamokovarov/jump/releases/download/v0.40.0/jump-0.40.0-1.x86_64.rpm && sudo rpm -i jump-0.40.0-1.x86_64.rpm
Nix nix-env -iA nixpkgs.jump
Go go get github.com/gsamokovarov/jump

Integration

Jump needs to be integrated with the shell. For bash and zsh, the line below needs to be in ~/.bashrc, ~/bash_profile or ~/.zshrc:

eval "$(jump shell)"
Enter fullscreen mode Exit fullscreen mode

For fish shell, put the line below needs to be in ~/.config/fish/config.fish:

status --is-interactive; and source (jump shell fish | psub)

Once integrated, jump will automatically monitor directory changes and start building an internal database.

But j is not my favourite letter!

โ€ฆ

Discussion (14)

Collapse
vonheikemen profile image
Heiker

Speaking of creating your own cli tools. I would like to share something cool: a scripting language called ABS.

This is why I think is cool.

  • It has a C-like syntax.
  • You can call external commands and handle the result in a convenient way.
  • It has a module system.
  • It has a builtin tool that allows you to create cli tools.

Here is a little snippet.

tz = `cat /etc/timezone`

if !tz.ok {
  echo("Ooops, something went wrong")
  exit(1)
}

continent, city = tz.split("/")

echo("Best city in the world?")

selection = stdin()

if selection == city {
  echo("You might be biased...")
} else {
  echo("Yes, ${selection} is awesome.")
}
Enter fullscreen mode Exit fullscreen mode

I wrote about this language a few years ago, here is the post if anyone is interested.

I like this a lot because it allows people who are familiar with a languages like javascript or PHP (that would be me) to write shell scripts in a way that feels comfortable.

Collapse
bravoecho profile image
B.E.

TUI file managers such as nnn (github.com/jarun/nnn, minimalistic, my favourite) or lf (github.com/gokcehan/lf/, a more interactive one)

delta, more limited than lazygit, focused on just diffs, but it does it really really well, and can be a nice complement (github.com/dandavison/delta)

glow terminal markdown renderer (github.com/charmbracelet/glow): some might think this is superfluous, because markdown is supposed to be meaningfully readable as plain text, but I often find poorly formatted files, sometimes "augmented" with a lot of inline HTML, to the point of becoming impossible to parse for the human eye

Collapse
pieter profile image
Pieter D

If bat looks appealing to you and you happen to be a Vim user, you might want to consider running view /path/to/file instead of bat. It'll open any file as readonly in Vim, with all your favorite plugins like Git integration present. Instead of piping to | less, you could also pipe to | view -. You may have to enter something like :set syntax=json if the syntax isn't autodetected based on content, although there's probably a simple setting or plugin to enable autodetection.

If you're not a Vim user and you want something that works with zero configuration, bat seems like a good choice!

Collapse
bravoecho profile image
B.E.

jump (github.com/gsamokovarov/jump) is in my opinion a better alternative to autojump

I personally prefer jump because it's actively maintained, but especially because โ€“ like all modern tools listed here โ€“ it's a standalone executable that does not require Python

it works really well, the author says it can "read his mind" and I tend to agree ๐Ÿ™‚

Collapse
jmfayard profile image
Collapse
dazfuller profile image
Darren Fuller

Iโ€™m using ripgrep and bat daily, and they make everything just that much better.

Another tool Iโ€™m using a lot is Just. I might have processes which need a number of steps, or building a project with a lot of arguments. I can abstract it all away and use something like โ€œjust buildโ€ instead.

github.com/casey/just

Collapse
jmfayard profile image
Collapse
jmfayard profile image
Collapse
siddharthshyniben profile image
Siddharth

Hey! I made this CLI tool called fcd which replaces the cd command. It basically searches for wherever you are trying to cd and then copies the appropriate cd command to your clipboard.

GitHub logo SiddharthShyniben / fcd

Faster cd-ing.

Contributors Forks Downloads Stargazers Issues MIT License


>_

fcd

Better cding for macOS
Explore the docs ยป

Report Bug ยท Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Documentation
  5. Roadmap
  6. Contributing
  7. License
  8. Contact

About The Project

Please star this repo if you found this tool useful ๐ŸŒŸ

fcd Screen Shot

fcd is a utility which helps you cd faster on macOS.

Ever had to type out a long cd ~/Sites/Projects/project, find out the path is wrong, rewrite it to cd ~/Sites/Sandbox/project? You just wasted a minute or two. This inspired me to create this tool: fcd.

fcd automatically reads the dirname and the basename of the input and searches for any folder with basename as the name in the dirname folder (Basically, if you input "some/where/else", the program returns the path to "some/where/**/else"). Once it finishes:

  • If there is more than one folder named basename, it gives youโ€ฆ
Collapse
siddharthshyniben profile image
Siddharth

I wanted to implement autojump like functionality ever since I made fcd.

Collapse
eggbean profile image
eggbean

If you want exa to behave just like ls, so that you do not need to learn any new switches, I have made this wrapper script:
gist.github.com/eggbean/74db77c4f6...

Collapse
joeklemmer profile image
Joe Klemmer

I've found lazygit to be quite handy, myself.

github.com/jesseduffield/lazygit

Collapse
Collapse
klvenky profile image
Venkatesh KL

Z is similar to autojump & works great for me.

Forem Open with the Forem app