Fast directory access in your command line.
I created a small gem to easily navigate to a "bookmarked" directory.
The gem is called yoke and it creates an alias for the directory your in with the current directory name. (or a custom name as you prefer)
Here is a small example on how to use this.
> cd ~/projects/myproject
> yoke
##########################
### YOKE #################
##########################
###
### Added Projects as alias for /Users/jellevandebeeck/...
###
### You should reload the 'yoke' aliases defined in your...
### You can do this by executing the following command:
###
### source ~/.yoke
###
### Or just start another shell and the aliases ...
###
##########################
Now an alias for ~/projects/myproject is created. Just run myproject in another shell in order to go to this directory.
> pwd
/Users/jellevandebeeck
> myproject
> pwd
/Users/jellevandebeeck/projects/myproject
Makes my terminal life a lot easier!
† Currently works best in the ZSH shell, working on a fix for BASH shells.
Written by Jelle Vandebeeck
Related protips
6 Responses
nice. you can also do this in .zshrc by simply creating alias.

True. But I hate going into that file al the time, so typing 'yoke' was much faster! :)

Cool tool!
What happens if you execute yoke
in, say, /usr/local/python
? Did you just alias python
to a directory, or are there safeguards in place? I see in your code that you're making sure you're not re-aliasing an already existing alias with
if list.has_key?(name)
false
but I didn't dig deep enough to see if you're checking everything in the PATH.

Hi Rick,
I currently don't check aliases like this. I presume the user would be smart enough not to make them. But maybe it's a good idea not to allow this kind of aliases. Thanks for the reply!

nice.
there's also fasd, which may be al little harder to setup, but makes you teleport in your filesystem.

Yeah, I could go either way on the protecting the PATH front. On the one hand, I like the idea of expecting users to know enough about their environment to not re-alias something. On the other hand, if you want to use this in a shared environment, it's more responsible to check all of the current aliases and the PATH before creating a new alias, so using this in a shared environment would require looking through the bash profile anyway (if there isn't a check).
In other news, I like that you called it "Yoke". It's short and sweet, while really symbolizing the action. Great work!