5 Awesome Command Line Tools for Python Developers

Anand Tripathi
Oct 9, 2020 · 6 min read

That’s cool right! The Terminal is the most used tool by developers. We spent most of our time in Terminal and sometimes it’s even hard when it comes to using a Mouse and a GUI. Some developers even go the extra mile to supercharge their terminal. So let’s become like those developers.

Let’s not waste our super valuable time and directly dive into the blog!

1. Bpython

bpython is a lightweight Python interpreter that adds several features common to IDEs. These features include syntax highlighting, expected parameter list, auto-indentation, and autocompletion. (See below for example usage).

If you have pip then simply run

$ pip install bpython

Some of you might be thinking that why Bpython instead of Ipython?

Bpython provides out of the box auto-completion that Ipython doesn’t support. Readline-like autocomplete, with suggestions displayed as you type. It also gives you the suggestion according to your history inputs. If you are interested to build something like this, then do checkout python-prompt-toolkit library.

In-line syntax highlighting. This uses Pygments for lexing the code as you type, and colours appropriately. In the above example, you can see the syntax highlights with different colours.

As in a lot of modern IDEs, bpython will attempt to display a list of parameters for any function you call. The inspect module is tried first, which works with any Python function, and then pydoc if that fails.

2. Fish Shell

Fishshell is a smart and user-friendly command-line shell for Linux, macOS, and the rest of the family. Basically, it's a supercharged Shell environment on top of bash that will give you some awesome features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.

Follow the GitHub link for the complete installation procedure

macOS

$ brew install fish

Ubuntu

sudo apt-add-repository ppa:fish-shell/release-3
sudo apt-get update
sudo apt-get install fish

Now again, some of you might say why Fish Shell instead of Zsh?

Fish shell is having autosuggestions that most of the other shell have not. You can also configure some cool plugins and themes using oh-my-fish(same as oh-my-zsh)

Just try fish out using this online terminal if you have any second thought on this.

3. PGcli

PGcli is a Postgres client that does auto-completion and syntax highlighting. The master project(DBCli) is also having mycli and litecli option for Mysql and SQLLite databases. If you truly love terminal and were using different IDEs for SQL then this is the time to say goodbye to GUI based IDEs.

$ pip install -U pgcli

or

$ sudo apt-get install pgcli # Only on Debian based Linux (e.g. Ubuntu, Mint, etc)
$ brew install pgcli # Only on macOS

The pgcli is written using prompt_toolkit.

  • Auto-completes as you type for SQL keywords as well as tables and columns in the database.
  • Syntax highlighting using Pygments.
  • Smart-completion (enabled by default) will suggest context-sensitive completion.
  • SELECT * FROM <tab> will only show table names.
  • SELECT * FROM users WHERE <tab> will only show column names.
  • The primitive support for psql back-slash commands.
  • Pretty prints tabular data.

4. Tig

Tig is a 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.

Installation

Follow the link for complete installation steps and macOS just use Homebrew.

$ brew install tig

It gives you options like

  • tig log will give you the log of git commits just like git log but additionally give you the file changes and if you want to check all the changes of the commit version you can do so by using tig as well without writing any extra commands
  • tig show <commit version> will give you the brief diff of the commit version.

5. awless

Last but not least is awless. awless is a powerful, innovative and small surface command-line interface (CLI) to manage Amazon Web Services.

Installation

Please check out the link for complete installation steps or if you are using macOS then simply use Homebrew for it.

$ brew tap wallix/awless; brew install awless

awless as the name suggests is the less version of awscli. If you are struggling with normal lengthy awscli commands then awless comes to the rescue. The output of awless is also giving us to the point information, nothing much and nothing less.

awless is having very simple commands like

$ awless list instances # list instances
$ awless list users # list users
$ awless list volumes # list volumes
$ awless ls vpcs --tag-key Dept --tag-key Internal --format tsv
$ awless ls instances --tag Env=Production,Dept=Marketing
$ awless ls instances --filter state=running,type=micro --format json
$ awless ls s3objects --filter bucket=pdf-bucket -r us-west-2
$ ...
(see awless ls -h)

Addons

Without add-ons, nothing is felt like completed right. So here is my curated list of addons for the CLI.

Check whether a website is up or down using the isitup.org API

All the Command line GIF that you have seen in this blog is created from this CLI tool only. ttygif converts a ttyrec file into gif files. It’s a stripped-down version of ttyplay that screenshots every frame.

Instant coding answers via the command line. If you love checkout StackOverflow for getting answers then you will love this tool. This tool will fetch answers from StackOverflow inside the CLI only.

Examples

$ howdoi print stack trace python
> import traceback
>
> try:
> 1/0
> except:
> print '>>> traceback <<<'
> traceback.print_exc()
> print '>>> end of traceback <<<'
> traceback.print_exc()

$ howdoi convert mp4 to animated gif
> video=/path/to/video.avi
> outdir=/path/to/output.gif
> mplayer "$video" \
> -ao null \
> -ss "00:01:00" \ # starting point
> -endpos 10 \ # duration in second
> -vo gif89a:fps=13:output=$outdir \
> -vf scale=240:180

$ howdoi create tar archive
> tar -cf backup.tar --exclude "www/subf3" www

Test your download and upload speed using fast.com

Conclusion

There is nothing right or wrong when it comes to customising your tools. So this was my curated list of awesome command-line tools for developers. I hope, it has helped you. If you want to discuss anything or anything related to tech, you can contact me here or on my personal blog Progress Story.

KOKO Networks

Engineering under the hood