---
title: "Terminal: a better way to navigate using ad"
description: Several years and thousands of 'cd some/path' later I finally decided to stop manually traversing directories. I will never get back those lost keystrokes.
---

[Home](https://mutuallyhuman-pr-605.herokuapp.com/)

- [Team](https://mutuallyhuman-pr-605.herokuapp.com/team)
- [Work](https://mutuallyhuman-pr-605.herokuapp.com/work)
- [Blog](https://mutuallyhuman-pr-605.herokuapp.com/blog)
- [Contact](https://mutuallyhuman-pr-605.herokuapp.com/contacts)

# Terminal: a better way to navigate using ad

By [Zach Dennis](https://resources.mutuallyhuman.com/test/author/zach-dennis) on 27 02 2009

Over the years I've used my own aliases in .profile (or .bashrc) as well as bash functions, perl scripts, etc produced by coworkers or random people on the internet to allow me to more easily navigate to a directory. At its heart the most basic way is a simple bash alias:

```
alias somedir='cd somedir'
```

While this works it requires me to open up my .profile or .bashrc file in an editor, find where I place aliases, add the alias, save the file, and source it so I have access to it. If you want to change an alias you have to essentially follow the exact same steps. Way too much manual work regardless of the tools being used. The workflow should be one step: tell your terminal you want an alias. And then it should just work. Overwriting an alias should simply be one step as well: tell your terminal you want an alias.

The result of this desire is a bash function and a ruby script: *ad* and *aliasdir.rb*. Together, these two things give you a one-step workflow for aliasing directories. They are a little win against effort and redundancy in the name of simplicity and *just-working-ness*. Yes, [ness](https://www.youtube.com/watch?v=Q8sU0UYzaSA).

### Using ad

```
# navigate to some directory
cd projects/opensource/webrat
# tell ad to store an alias to this directory ad webrat
# now anytime you want to navigate to webrat just # type the alias name webrat
```

### How it works

*ad* is a bash function that wraps aliasdir.rb. You invoke this in terminal and it will set up the alias in your current session, and it will use aliasdir.rb to store it. When you open a new terminal session it will just be available.

*aliasdir.rb* is a ruby script that stores aliases for changing directories. It’s used by *ad* and you don’t need to interact with yourself, although you can if you want; see *aliasdir.rb -h*.

### Installing

ad and aliasdir.rb are stored on github in MHS’s [tidbits](http://github.com/mhs/tidbits/) project. Clone and create a symlink:

```
git clone git://github.com/mhs/tidbits.git
ln -s /path/to/tidbits ~/.tidbits
```

Lastly, copy the ad function below into your .profile, .bashrc, or whatever file is appropriate:

```
# ad is for *alias directory*. It creates persistent
# aliases. Type 'ad -h' for help.
function ad
{
  ~/.tidbits/lib/aliasdir.rb $@
  eval `~/.tidbits/lib/aliasdir.rb --dump`
}
eval `~/.tidbits/lib/aliasdir.rb --dump
```

You will need to source the file to make the *ad* function available to you or you will need to open a new terminal session. This is a one time thing.

Enjoy using *ad*.

### Related Topics

- [Uncategorized (106)](https://resources.mutuallyhuman.com/test/topic/uncategorized)
- [User Experience (20)](https://resources.mutuallyhuman.com/test/topic/user-experience)
- [Ruby (11)](https://resources.mutuallyhuman.com/test/topic/ruby)
- [Interaction Design (10)](https://resources.mutuallyhuman.com/test/topic/interaction-design)
- [JavaScript (9)](https://resources.mutuallyhuman.com/test/topic/javascript)

### Related Posts

### About Mutually Human

Mutually Human is a custom software design and development consultancy specializing in mobile and web-based products and services. We help our clients design, develop and bring to market innovative products and services based on insightful research and strategy aligned with business objectives. We’ve helped Fortune 500 companies, state governments, and startups.

- [Home](https://www.mutuallyhuman.com)
- [Team](https://www.mutuallyhuman.com/team)
- [Work](https://www.mutuallyhuman.com/work)
- [Blog](https://www.mutuallyhuman.com/blog)
- [Contact](https://www.mutuallyhuman.com/contacts)

logo

[Mutually Human Grand Rapids: 401 Hall St. SW Suite 430 Grand Rapids, MI 49503 USA](https://www.mutuallyhuman.com/contacts#grand-rapids)

[Mutually Human Columbus: 243 N. Fifth Street Suite 300 Columbus, OH 43215 USA](https://www.mutuallyhuman.com/contacts#columbus)

+1 616 475-4225

[hello@mutuallyhuman.com](mailto:hello@mutuallyhuman.com)

<https://twitter.com/mutuallyhuman/><https://www.linkedin.com/company/mutually-human-software> <https://www.facebook.com/mutuallyhuman/> <https://github.com/mhs>

© 2017 Mutually Human