40

5 CLI Utilities to Boost Your Productivity

 4 years ago
source link: https://www.tuicool.com/articles/hit/FveIFb2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Here are 5 command line tools I've found recently which can speed up your workflow.

fx , a command-line JSON processing tool

fx ( GitHub ) is a CLI tool written in JavaScript which allows you to process JSON using your terminal.

zY7b2an.gif

You can explore and modify JSON using small snippets of plain JavaScript, and use your cursor to dive into the structure. For all of the functionality offered by fx , check out the documentation .

Installing fx

  • brew install fx

http-prompt , for interacting with APIs

http-prompt ( website ) is useful for exploring and interacting with HTTP APIs. It comes with autocomplete and syntax highlighting.

BZvIryu.gif

http-prompt is written in Python, and builds on top of HTTPie , which was covered earlier in this series.

Installing http-prompt

  • pip install --user http-prompt

fselect , for querying files with an SQL-like syntax

fselect ( GitHub ) is an alternative way to search your filesystem. It lets you use a syntax similar to SQL to find what you're looking for. For example, to find the size and path of all .cfg and .tmp files in /home/user/ :

fselect size, path from /home/user where name = '*.cfg' or name = '*.tmp'

fselect also supports aggregation functions, similar to those you find in SQL:

fselect "MIN(size), MAX(size), AVG(size), SUM(size), COUNT(*) from /home/user/Downloads"

The query above will find the smallest file size, the largest file size, the average file size, the total file size, and the number of files present in your Downloads folder.

fselect is written in Rust, and it can do much more than the examples above suggest. It has extensive documentation .

Installing fselect

  • brew install fselect

ranger , a command-line file manager

ranger ( GitHub ) is a command-line file manager written in Python that lets you browse and manipulate your file system using Vim like keybindings.

qY7FzmQ.png!web

It offers a multi-column display, the ability to preview files, and lets you perform common file operations (such as creation, deletion, chmod, copying, etc.) from within the ranger interface.

You can extend ranger by installing some Python packages which allow it to preview images, HTML documents, and PDF files. The image below is an example posted on the gallery available on the Ranger website, showing the image previewing functionality in action.

yMVNju3.jpg!web

Ranger is a deep piece of software with countless features that don't fit within the scope of this post. More information can be found in the official user guide .

Installing ranger

  • brew install ranger

tokei , to view statistics on your code

tokei ( GitHub ) lets you view code statistics for your projects by breaking down the languages you've used. It's written in Rust, which helps make it very fast .

Here's some example output from running tokei in my Advent of Code folder:

-------------------------------------------------------------------------------
 Language            Files        Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 Markdown                1          165          165            0            0
 Rust                   13         1071          854           51          166
 Plain Text             17         4032         4032            0            0
 TOML                    1           11           10            0            1
-------------------------------------------------------------------------------
 Total                  32         5279         5061           51          167
-------------------------------------------------------------------------------

Installing tokei

  • brew install tokei

Conclusion

Thanks for reading! Hopefully, you found something on this page that interests you. If you’re interested in more content like this, follow me on Twitter and onDEV!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK