Skip to main content

Command line tools for a happy life

Hello Readers!

I'm back and better than ever with another article about developer productivity. I love the Terminal. After all that's where everything comes to an end.  Or begins. (Only nerds get that joke.) 

Today I'm going to discuss four (yes, just 4) cool *nix tools, utilities that help you get things done faster once you integrate them into your workflow.

  1. tmux
  2. tree
  3. find
  4. ripgrep

 

tmux

tmux is a multiplexor. Do you log in to remote servers using ssh clients, like ssh and/or putty? Do you have to spawn multiple of those just to get more done? Does that slow you down? Of course it does.

Well, look no further.  Spawn one terminal and invoke the tmux. That's all you need!

Spawn it with: $tmux 

Note: tmux may not be available by default. To install it, use your favorite package manager. This screen cast demos how to use tmux. 

 

Tmux, click for demo


tree

tree provides a nice layout of the directory structure in your terminal. Don't get me wrong: I don't have a dislike for UI. I like visual representations, and sometimes looking up the directory structure is more important. This is where tree comes into play. You don't have to spawn an IDE to see how your directory structure looks. You also don't have to go in and out constantly using cd commands to make sense of the structure. That's a lot of cognitive load.

Invoke it with: $tree

Are you going to run tree on a top level directory? If so, that will be a big tree! Pipe it to less ($ tree | less), and you can navigate up down using j and k. (Yup, Vim commands work here too!) Use gg or G to go to the top or bottom of the document respectively. It's amazing how knowledge of Vim bindings works across *nix tools. 

tree, click for demo



find

I'm sure a lot of you know this, but for those who don't....  Let's say you have to do a quick recursive find. You are in some directory and want to search for a file inside the directory recursively. 

Here's the command: $find . -name BUILD 

Now let's break it down.

.  is the current directory 

-name is the parameter to indicate the file name

This will look recursively for a file BUILD inside the current directory. It will not stop at the first instance. Rather it will get you more. 


find click for demo

ripgrep 

Ripgrep is grep -R on steroids. Let's say you want to find files which have a certain text within a file. Use ripgrep abbreviated as rg.

Note: ​​​​​​​This tool may not be available by default. Use your favorite package manager to install it. Click here to read more.

Here's an example of the command: $rg -e "dart"

This will list all the files which include the word "dart." Isn't that awesome? 

For even more awesomeness, use Vim with ripgrep. It will search and quickly load the file in the buffer.

ripgrep click for demo

What are your favorite command lines tools? Please share. I will be happy to learn from you! 


Comments

Popular posts from this blog

Chat GPT and our(dev) future

 There's a lot of hype and anxiety over large language models like Chat GPT. Companies are scrambling to come up with their next AI offering as soon as possible to counter GPT. I've been thinking about how it will affect us as engineers and our company in the near future and in the longer term. Please read what follows with a grain of salt, as this is my opinion only. What is GPT capable of? GPT is an intelligent chat bot backed by a language model which can answer your questions contextually and make it appear creative.  It allows you to do your job faster.  Will GPT help us get to MVP faster? Maybe. It can write code but only in snippets. You're still responsible for gluing the code together.  Today it’s a fast stack overflow.    Will GPT replace you?  Certainly not in the near term. Software engineering is about communication. A stakeholder won’t be able to communicate with GPT and get an MVP.  As an engineer, you...

Configuring VIM

Let's configure VIM In this post, we will look at the basics for configuring Vim. Vim has some reasonable defaults, but it is malleable, so you can shape it to your needs. Master craftsmen all have a favorite tool which is custom-made and tailored to their needs. That is what Vim is for writers and programmers.  Let's get down to business. Locate your configuration file. If you're using Vim ~/.vimrc in your home directory is the file you will use to configure Vim.  If you're using Neovim ~/.config/nvim/init.vim  in your home directory is the file you will use to configure Neovim.   The standard workflow is to edit the vimrc/init file, exit Vim, and launch it again so the configuration take effects. (Optionally, you could source the file in command mode.) If vimrc is open in your terminal, just enter the following command: so % . "so" is the shorter form for "source" and "%" refers to current buffer.  This configuration is the same for ...