Bookmark The Linux Commands For Easier Repeated Invocation

A while ago, we have written about “Keep” utility, which is used to save the Linux commands in Terminal and use them on demand. It is quite useful when it comes to use lengthy Linux commands often. We don’t have to memorize the commands. Just save it using “Keep” utility and use that command on demand. Today, I have stumbled upon yet another similar utility called “Bashpast”. It is used to bookmark the linux commands for easier repeated invocation. This provides an easy way to repeat frequently used commands and saves you few keystrokes. Also, if you have hard time remembering lengthy commands, you can use it to bookmark them. Of course, you can simply do a reverse search using ‘CTRL-R’ to lookup the commands or use aliases, but this utility provides way faster and easier method.

Bashpast  – Bookmark The Linux Commands

Install Bashpast

Git clone the Bashpast GITHub repository using command:

git clone https://github.com/ivanmisic/bashpast.git

The above command will clone the contents of Bashpast repository in your current working directory.

Go to bashpast directory:

cd bashpast/

And, run the following command to install it.

make

Append the following line in your ~/.bashrc file:

vi ~/.bashrc

Add the following line:

source ~/.local/bin/bashpast.sh

Finally, update your .bashrc file with the command:

source ~/.bashrc

Bashpast has been installed now. Next, we will see how to use it to bookmark the Linux commands.

Bashpast usage

Let us say you want to find and copy all files that ends with extension .mp4 and save them in a directory called Downloads. To do so, we use the following command:

find -iname '*.mp4' -exec cp {} /home/sk/Downloads/ \;

As you can see, this command is longer, and difficult to keep it in memory all the time. In such cases, Bashpast will make your life easier. You can simply bookmark the above commands and use them on demand.

Please keep in mind that you need to run the command before bookmarking it. Let us bookmark it using command:

bp s find

The ‘find’ command has been bookmarked. To execute this command, run:

bp e find

Let us bookmark another command. First, run the actual command:

ls -l

Bookmark the above command:

bp s ls

To execute the bookmarked command, do:

$ bp e ls
total 8668
drwxrwxr-x 3 sk sk 4096 Jul 22 14:09 bashpast
-rw-r--r-- 1 sk sk 5123 Jul 11 18:24 client.ovpn
drwxrwxr-x 14 sk sk 4096 Jul 20 17:39 ostechnix
-rw-rw-r-- 1 sk sk 8858480 Jul 20 16:59 sk

See? It executes the bookmarked command and displays its result.

To list all bookmarks, run:

bp l

Sample output:

ls                   ls -l
find                 find -iname '*.mp4' -exec cp

Bashpast

As you can see in the above outputs, Bashpast bookmarks the given commands and executes them without having to type the actual command. If you want to bookmark the same command multiple times, just name it with different name, such as find1, find2, find3 and so on.

And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned!

Cheers!!

Resource:

Author: lamichhane kamal

System administrator Unix. Experinced Author Always with new idea. Contact me If you need help about Linux or windows server.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
36 ⁄ 12 =