Skip to content

NicholasBHubbard/mycd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

A bash function that wraps cd to log your directory history.

Why Does This Exist?

It is extremely common to need to go back to a directory you’ve visited recently. mycd exists to solve this problem in the simplest way possible by remembering the last 15 (by default) directories you’ve visited and providing a simple way to list and jump to these directories. The directory history is saved across sessions, and each user gets their own history.

Installation

git clone https://github.com/NicholasBHubbard/mycd
cp mycd/mycd.bash /etc/profile.d/

You can of course install mycd.bash to any directory you wish.

Next you will need to source mycd.bash from your .bashrc. It is also recommended that you alias cd to mycd. Add the following lines to your .bashrc.

if [ -r $DIR/mycd.bash ]; then
   . $DIR/mycd.bash
   alias cd=mycd
fi

Usage

mycd works the same way as regular cd except it accepts two special arguments.

The first special argument is -- which lists your directory history.

[nick@slacktop ~]$ cd --
   1	/home/nick
   2	/etc/rc.d
   3	/home/nick/Pictures
   4	/
   5	/etc

The second special argument is -N where N is one of the numbers listed in the -- output. This changes your directory to the N‘th directory in your history.

[nick@slacktop ~]$ cd -3
[nick@slacktop Pictures]$ 

Customization

The MYCD_HIST_LENGTH variable can be set to control the number of history items that are remembered. This value defaults to 15.

License

MIT

About

Directory history for Bash

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages