DEV Community

Cover image for Creating a smart alternative to 'cd' command

Creating a smart alternative to 'cd' command

Bhupesh Varshney 👾 on August 03, 2020

Do you sometimes forget the actual location of directories & have to juggle through cd & ls to know the right path? In this short post, we ...
Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Install z - it's awesome - github.com/rupa/z

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

Did you mean the Z Shell ?. It actually is great but it's limited compared to features available in bash

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Nope - check out the GitHub link

Collapse
 
vonheikemen profile image
Heiker

I want to hear about these bash features that zsh doesn't have.

Thread Thread
 
bhupesh profile image
Bhupesh Varshney 👾 • Edited

mapfile/readarray for example is a very handy thing in bash which is not in zsh
Another one which I like read -p "Enter Password" doesn't work in zsh

Collapse
 
juniordevforlife profile image
Jason F

Thanks for this Bhupesh. My team lead at my previous job introduced me to Bash aliases. I created a few aliases to help me with navigating to files and directories that I used every day. I'd never thought to go beyond that, but after seeing your post I may have to tinker with it. Thanks again!

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

Thanks a lot (you are probably the first reader 🙈), glad it helped 🔥
I am still amazed by how much we can customize our shell

Collapse
 
taikedz profile image
Tai Kedzierski

That's pretty neat !

The only thing is.... why cd "$1" || exit ? If for some reason there's, say, a permission issue on that folder, or a broken symlink, exit will actually terminate your current shell session... surely not the effect you want from a function? Likely this should be return

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

Yes, I absolutely agree (the thing is I it realized sometime later after I first published the blog)
I have updated it now
thanks for pointing it out 👍

Collapse
 
idrisrampurawala profile image
Idris Rampurawala

You have opened up a new array of ideas with this post. Thanks. Keep it up bro! 😊

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

🤟🏼 thanks

Collapse
 
delta456 profile image
Swastik Baranwal

Thanks for this!