cd with weighted marks
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


cd with weighted marks

This is a script similar in functionality to Bash's pushd and popd builtin commands. Every time you change directory it updates a bookmarks file either by adding a new entry or by increasing the weight of an existing one. The marks with highest scores are at the top of the file so they get matched first.

The format is: weight directory (optional bookmark) Example: 3 /usr/src/linux

Once you've been to the above location you can return by simply typing:

c li (or any string part of the directory)

Note: You could also <tab> complete your filter in order to list all possible locations; c li<tab> will generate a list of bookmarked and default directories merged together. Use cx li<tab> if you want a bookmarked list only.

Filtering further is also possible:

c sr li will ensure you don't end up in /usr/share/lib if it has a higher score!

As an additional bonus you have the possibility to create a named bookmark by typing cb bookmark while in the desired location. A named bookmark must NOT contain spaces.


c /usr/src/linux
cb kernel

Now the entry is: 4 /usr/src/linux kernel, thus you could come back with c ker or c rne or ...


  • $ touch ~/.cdmarks
  • source the script in your ~/.bashrc
  • $ exec bash

You are ready!

Note 1: cs filter ... will list your bookmarks (similar to <tab> completion) and ci can help you with migrating a personal ~/.cdmarks.skel file

Note 2: Never use ~ in ~/.cdmarks.skel or if manually entering bookmarks in ~/.cdmarks (use the value of HOME instead). Don't terminate paths with a /

Note 3: If you want to use a different name than c, put alias new_name=cd_bookmarks after the source statement

Note 4: Get help with ch