Apparix: augmenting cd with bookmarks

1. 
2. 
3. 
4. 
5. 
6. 

1  Apparix

Apparix allows fast file system navigation by bookmarking directories and jumping to a bookmark directly. It integrates regular bookmarks with CDPATH-style bookmarks. Subdirectory specification and (bash) tab completion add further power. The apparix replacement for cd, called to, by default fully supplants cd. Bookmarks, subdirectories of the bookmark, and directories specified in the regular way can all be navigated and completed transparently.

 
  
 
  
 

2  Related

Apparix was inspired by cdargs. The HISTORY section in the manual has a few more remarks on that. The CDargs homepage lists two more cd-related applications. These are

wcd - wherever CD. This utility will scan any filesystem you throw at it. It is then possible to change/search directory by pattern and do a hundred things more. It was pointed out to me that on some Unix/Linux flavours locate does to a very large extent the same thing as wcd does - in creating a database describing file systems. Combine the locate resources with standard UNIX utilities such as grep in a small script such as goto, throw in CDargs or apparix, and your setup is small, adaptible, powerful, and uses existing resources. Still, I've tried wcd and it delivers what it promises.

kcd - k CD. Seems similar to CDargs. I've not been able to track the meaning of k. Possibly it is just the first initial of the author, Kriang Lerdsuwanakij. Hopefully it is not in the long and lamentable tradition of KDE kapplikations with klunky knames.

See also Sitaram Chamarty's bash goto functions.

3  What Everyone Should Know About Change Directory

cd -
  

takes you to the previous directory. The apparix equivalent is to - and does the same.

  
cd `pwd`
  

erases any symlink side-effects that your path may suffer from.

4  Pattern-based cd with goto

Sitaram Chamarty wrote a bash goto function that leverages the locate database or a user-created dump of file system locations. This is very useful for a) browsing and searching (new) file systems b) visiting locations in a hugely branched file hierarchy or when you want to range over many destinations (so that the bookmark approach is not a good fit) c) on systems where you somehow have such a minimal presence that you do not want to bother installing whatever file system navigation tools you normally use.

It is possible to ask for locations by directory name pattern and file name pattern, and it is possible to restrict matches to a specified directory that will act as root for the query.

goto can be thought of as a very convenient chimera of find and cd. It is complementary to bookmarking in that the latter provides unambiguous and instantaneous change of directory to what is presumably an oft-visited hotspot, where the mark is independent of its associated destination. goto can take you anywhere but may require zooming in by means of a selection menu, depending on the distinctiveness of the query string. The latter is used to match destinations directly.

Go to Sitaram's goto page.

5  Edit TODO, README, ChangeLog and other totem files

If you are a developer and maintain different code trees, you may want to bookmark those trees. Conceivably you bookmark the top of those trees and such a top typically contains TODO, README and ChangeLog files. You can use the mark to quickly jump to that location; alternatively one may use functions/macros to edit any one of those special files by specifying the mark.

Below, functions todo and clog are defined that expect a bookmark as argument. The result of the function will be to invoke an editor (vim in this case) on the corresponding TODO or ChangeLog file. So todo z would invoke the TODO file of the code tree bookmarked by the mark z.

# --- csh-style ---
alias todo     'vim `apparix \!*`/TODO'
alias clog     'vim `apparix \!*`/ChangeLog'

# --- bash-style ---
function toot () {
   if test "$3"; then
     vim "$(apparix -favour rOl "$1" "$2")/$3"
   elif test "$2"; then
     vim "$(apparix -favour rOl "$1")/$2"
   else
      echo "toot tag dir file OR toot tag file"
   fi
   pwd
}
function todo () {
   toot $@ TODO
}
function clog () {
   toot $@ ChangeLog
}

6  The cd conjecture

For 50% of people more than 10% of their shell keystrokes are spent on cd. For a remaining 30% that rises to over 20%. For the last 20% it rises to over 30%.

The last batch is evenly split over command line novices and veterans.