DEV Community

loading...
Cover image for How to Bookmark commands in Terminal

How to Bookmark commands in Terminal

Thamaraiselvam
I am a passionate person, who has been working as a Full Stack Developer for 4 years. I love GNU/Linux, Open Source Software
Originally published at thamaraiselvam.com ・1 min read

Always we hate to type or search or copy and paste most often used commands in the terminal.

I found a great tool to ease the navigation in the terminal, called Apparix. It lets you bookmark a folder so that you easily can navigate to it just by typing

to nameofbookmark

To install apparix in Ubuntu, type

sudo apt-get install apparix

To install in Mac, type

brew install -v apparix or Run this Script

in a terminal window.

After installation, you need to set up the aliases bm for bookmarking and to for going to a bookmark by adding a few functions to your .bashrc file in your home folder (if you don’t have this file, you can create it yourself).

You’ll find the functions you need to add by issuing the command

apparix –shell-examples

in a terminal window. Copy everything below Bash-style functions except the CSH-style aliases. Paste this into your .bashrc file.

Open up a new terminal, cd to your directory of choice and type

bm mybookmark

to bookmark the folder. Afterward, you can go to any folder and type

to mybookmark

to go to your bookmark.

This tool is, of course, available for other Linux distributions too.

Reference: https://micans.org/apparix/

Discussion (18)

Collapse
booyaa profile image
Mark Sta Ana

This is a nice idea will give it a go. Previously in bash I’ve used the hash (comment) to tag complex commands ie ls # complex Then used CTRL-R to recall them using the tag.

Fish shell has amazing mind reading abilities too, I know it’s mostly based on frequency of command history.

Collapse
thamaraiselvam profile image
Thamaraiselvam Author

Thanks for the comment :D

Collapse
mauroporras profile image
Mauro Porras • Edited

If you use zsh with oh-my-zsh, the wd plugin may be of your interest: github.com/robbyrussell/oh-my-zsh/...

Collapse
viveksoundrapandi profile image
Vivek Soundrapandi

I use zsh z(github.com/agkozak/zsh-z), auto remembers all directory by their names. No need to explicitly book mark

Collapse
mitchartemis profile image
Mitch Stanley

Ooh I like this 😀, I've just found the Fish shell port as well - github.com/jethrokuan/z

Collapse
thamaraiselvam profile image
Thamaraiselvam Author

Wow, it is good. does it work with the only directory?

Collapse
viveksoundrapandi profile image
Vivek Soundrapandi

No it works across any directory that we have visited at least one. Cool thing is it does partial match, most cases I just type 3-4 substring of directory names.
Z dev takes me to /users/... /development directory

Thread Thread
thamaraiselvam profile image
Thamaraiselvam Author

Great

Collapse
mapperr profile image
Michele Perrotta

I use autojump, that, AFAIK, it's similar to z.

Collapse
daviddasilva profile image
David Da Silva

+1 for autojump.
Jumping to a folder named "MyFooBar" is as simple as j foo*.

(*) Provided you have been at least once in this folder before.

Collapse
brpaz profile image
Bruno Paz

I use fzf-marks and zsh-z for folder navigation.

For commands pet is really nice.

Collapse
midblue profile image
Jasper Stephenson

This is a bit off topic, but I absolutely love the typeface in your header image. Do you remember what it is? :)

Collapse
thamaraiselvam profile image
Thamaraiselvam Author • Edited

Font name: Droid Sans

Conver image Created from blogcover.now.sh/

Collapse
thamaraiselvam profile image
Thamaraiselvam Author

Thanks for the comment, pushd, popd is a stack, we can't bookmark a command in a userdefined name and also I am not sure how difficult to manage n number of commands in the stack

Collapse
grepliz profile image
Liz Lam

It's possible to view an indexed version of the directory stack by using dirs -v and then pop the directory by index using popd +N. But bm and to definitely feels more intuitive.

Collapse
rootameen profile image
Ameen Ali

when there's a folder I usually navigate to, I cd into it using full path once so that i can use ctrl+r name_of_folder for faster access next time. Works on files, too, and uses built-in cli tools.

Collapse
vlasales profile image
Vlastimil Pospichal

I use symlinks, CDPATH and aliases. This is enought.