Ramesh Vishveshwar
By
April 26, 2019

BETTER AT THE TERMINAL

  GUI

In spite of running a full GUI Linux Mint desktop, there are many commands that I am more comfortable running from the command line. I am pretty sure it helps me to manage my VPSes better. This week’s article is about how you can enhance your command line experience.

how2

You may have untarred a .tar.gz file a hundred times, but you have your moments where you are not very clear on some options or flags. how2 is a nodejs script that you can install on your vps to ask questions that you would normally go to stackoverflow for. You can ask questions in an almost conversation like manner and you can get the results right on your terminal.

 

Results are displayed on screen and you have an option to view more choices or quit.

how2 is installed as below

$ npm install -g how-2

You can also query for other languages by passing the -l parameter followed by the language. You can ask how2 something like this

$ how2 -l python permutations of a list

AutoJump

Are you tired of having to type directory names in full every single time? Autojump can help by making it easy to navigate to often used folders by typing just part of the directory name.

Installation is as easy as

$ git clone git://github.com/wting/autojump.git

$ cd autojump

$ ./install.py

You can now use autojump using the wrapper j. Now, let autojump auto learn the directories you visit. Use your session like before and autojump keeps track of them. After a while, you can navigate to your nginx configuration directory by

$ j conf

Would take you to /etc/nginx/conf.d/

If you have a long named subdirectory, you could jc {partial-string} and you will jump into the sub-directory.

fzf

Fuzzy File Finder is a way to easily find files under the current directory. Imagine you are editing your new WordPress theme/plugin and have to traverse between directory and sub-directory, you will probably give up on the code. Yes, it is that frustrating. You can download fzf from their github page (https://github.com/junegunn/fzf-bin/releases) and add it to your path.

Fzf can be invoked from the command line by pressing the Ctrl+T buttons to open a small interactive search shell. For example, you are editing a file and you type in nano and then Ctrl+T, you can now search for the file you want, maybe functions.php. As you type in func, you can see the list of matches. Use the arrows to move up/down and press enter for the file to be added to your command.

bat

Bat is a way to view files with full syntax highlighting. It is a much better option that using cat/less to view file contents. Another open source tool, you can get it from github (https://github.com/sharkdp/bat).

 

https://camo.githubusercontent.com/9d3d89364f2cc83ace8f29646a6236bc15ea1da0/68747470733a2f2f696d6775722e636f6d2f724773646e44652e706e67

You can install it easily on most *nix environments, using the appropriate file in the release page. bat integrates with git to show you modifications and changes when you display a file.

Trash-cli

When you rm a file, it is gone – unrecoverable. To avoid instant (or delayed) regret in removing files and directories that you may want to use down the line, use trash-cli. You can install it from Github

$ git clone https://github.com/andreafrancia/trash-cli.git

$ cd trash-cli

$ sudo python setup.py install

To delete a file and put it in trash, use the command trash-put

$ trash-put file-not-needed.php

To recover, use trash-restore

$ trash-restore file-not-needed.php

To clear out the trash can and recover space, you can issue the trash-empty command.

Hyperfine

When you need to benchmark and get accurate details of how long your program takes, you need hyperfine. Written in rust, it is easily installed from the appropriate binary (https://github.com/sharkdp/hyperfine/releases)

Run hyperfine followed by the program/application and let it provide detailed information on how long it ran for

 

You can also provide parameters to vary the benchmark results. For e.g, using different number of threads in a make process to identify the optimal values.

$ hyperfine --prepare 'make clean' --parameter-scan num_threads 1 12 'make -j 
{num_threads}'

Do you have other smart tools that help you be better at the terminal? Let us know.

Popular Stories

The New ChicagoVPS Affiliate Program
INSTALL OUTLINE ON YOUR VPS
BETTER AT THE TERMINAL
ALTERNATIVES TO CPANEL
SCHEDULING PROCESSES
MONITORING NETWORK USAGE

Subscribe Email

Top