GiselleSerate / myaliases

Useful shell aliases and functions.
6 stars 1 forks source link

cds refactor #55

Closed aryarm closed 6 years ago

aryarm commented 6 years ago

The current code in cds will check first whether the supplied argument is a directory before it executes cd. This is a necessary check so that cds can decide whether to attempt to cd with a shortcut; if the directory doesn't exist, cds tries one of its shortcuts.

I realized though that cd probably does this check itself, and likely a whole bunch of others too. So what's the point in guessing what those checks are and then hard-coding them into cds like I've been doing? Back when I first started, I didn't have a way to first attempt to execute \cd and then try a shortcut if it didn't work... ...until I learned about exit codes 😀

This refactor will finally be the breaking point after which I would be comfortable aliasing cd to cds by default when people run setup 😄 After this point, cds will literally be executing cd before it tries its stuff and there's no better way to create a wrapper function than that, right?

What do you think, @GiselleSerate? Should I do it?

Other Possible Upsides: significantly simplifies the code for cds; makes cds more compatible with other shells Possible Downsides: makes cds ever so slightly slower to jump to a shortcut but makes it faster to jump to a regular directory

GiselleSerate commented 6 years ago

This sounds like a very good idea! I like it a lot (and is similar to what I did with altalias, we'll see about whether I can use exit codes). go for it 😀