.\" Copyright (c) 2011 Stijn van Dongen .TH "apparix" 1 "3 Mar 2011" "apparix 1\&.004, 11-062" "USER COMMANDS " .po 2m .de ZI .\" Zoem Indent/Itemize macro I. .br 'in +\\$1 .nr xa 0 .nr xa -\\$1 .nr xb \\$1 .nr xb -\\w'\\$2' \h'|\\n(xau'\\$2\h'\\n(xbu'\\ .. .de ZJ .br .\" Zoem Indent/Itemize macro II. 'in +\\$1 'in +\\$2 .nr xa 0 .nr xa -\\$2 .nr xa -\\w'\\$3' .nr xb \\$2 \h'|\\n(xau'\\$3\h'\\n(xbu'\\ .. .if n .ll -2m .am SH .ie n .in 4m .el .in 8m .. .SH NAME apparix \- augmenting cd with bookmarks .SH SYNOPSIS Apparix allows you to bookmark directories and later jump to them using the mark\&. By default apparix acts as a replacement for \fIcd\fP and can be used in the same manner, including the special behaviour for \fIcd\fP without argument and \fIcd\fP\ \&\fC-\fP\&. It is possible to directly jump to subdirectories of a bookmarked directory\&. The contributed bash completion code facilitates completion both on bookmarks and directories, but can be adjusted to accommodate other preferences\&. This manual page suffers from an excess in verbosity due to the many examples, explanations of the bells and whistles, and comparisons with other approaches to bookmarking\&. The fundamental idea is simply that typing a string of your own choosing takes you to the directory associated with it\&. Apparix does little more than maintaining a list of keys and values\&. It obtains directory names and listings, associates path names (values) with bookmarks (keys), and has some facilities for manipulating keys and values\&. The functions involving apparix (\fBbm\fP, \fBto\fP, and \fBportal\fP) provide the user interface\&. Other functions, \fBals\fP (apparix ls) and \fBae\fP (apparix edit) are discussed on the main apparix page http://micans\&.org/apparix\&. .SH GETTING STARTED Install apparix\&. This should be as easy as \fC\&./configure --prefix=$HOME/local && make && make install\fP, or perhaps a pre-packaged apparix is available for your system\&. Then get hold of the \fBto\fP, \fBbm\fP and \fBportal\fP shell handles\&. These are either aliases or functions depending on your shell\&. Currently csh-style shells and bash are supported\&. Get the ones you need preferably from http://micans\&.org/apparix/#shell\&. For a more limited set of commands either visit the \fBFILES\fP section, or issue \fCapparix --shell-examples\fP\&. Activate them by simply pasting them in a shell or adding them to the appropriate resource file, e\&.g\&. \fC$HOME/\&.cshrc\fP or \fC$HOME/\&.bashrc\fP (do not forget to \fIsource\fP the resource file)\&. The handles \fBto\fP, \fBbm\fP and \fBportal\fP can of course be changed to any name desired\&. With these preliminaries, the following is a mock-up shell navigation session\&. .di ZV .in 0 .nf \fC > \fBpwd\fP /home/eez/cvs/xyz/tfa/faq/zut/bar/foo > \fBls\fP src/ doc/ CVS/ bin/ > \fBbm xkr\fP # bookmark as xkr (funny name though) > \fBbm\fP # bookmark as foo (trailing component is default) (later) > \fBto xkr\fP # cd to /home/eez/cvs/xyz/tfa/faq/zut/bar/foo (alternatively) > \fBto xkr src\fP # cd to /home/eez/cvs/xyz/tfa/faq/zut/bar/foo/src (alternatively) > \fBto foo\fP # cd to /home/eez/cvs/xyz/tfa/faq/zut/bar/foo (later) > \fBls\fP aap pyu/ qua tim/ zut/ > \fBpwd\fP /home/eez/another/branch/deep/down/under > \fBportal\fP # bookmark as portal, imports tim zut pyu bookmarks added flock of 3 in portal /home/eez/another/branch/deep/down/under (later) > \fBto zut\fP # cd to /home/eez/another/branch/deep/down/under/zut (later) > \fBapparix\fP # show all bookmarks --- portals e /home/eez/another/branch/deep/down/under --- expansions j pyu /home/eez/another/branch/deep/down/under/pyu j tim /home/eez/another/branch/deep/down/under/tim j zut /home/eez/another/branch/deep/down/under/zut --- bookmarks j xkr /home/eez/cvs/xyz/tfa/faq/zut/bar/foo j foo /home/eez/cvs/xyz/tfa/faq/zut/bar/foo .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR In the last example apparix simply shows all its bookmarks\&. The first batch shows portals\&. The second batch shows secondary bookmarks expanded from portals\&. The third batch shows all regular bookmarks\&. In the default definitions of \fBto\fP it falls back to regular \fIcd\fP behaviour in case a mark is not found\&. This is done by instructing apparix to check whether the mark exists as the name of a directory\&. It is possible to do this either before or after bookmark lookup, or not at all\&. By default the bash completion code takes into account both bookmarks and directories\&. Apparix also allows subdirectory specification of bookmarked locations\&. If this is combined with the bash completion code it yields a powerful way of navigating container directories, i\&.e\&. directories that contain a large number of subdirectories\&. Refer to the \fBsubdirectory specification\fP section\&. \fBFurther options\fP .br \fB[--add-mark\fP (\fIadd jump bookmark\fP)\fB]\fP \fB[--add-portal\fP (\fIadd portal bookmark\fP)\fB]\fP \fB[-sm\fP (\fIsquash repeated marks\fP)\fB]\fP \fB[-sd\fP (\fIsquash repeated destinations\fP)\fB]\fP \fB[-lm\fP (\fIlist bookmarks with this mark\fP)\fB]\fP \fB[-ld\fP (\fIlist destinations with mark indirection\fP)\fB]\fP \fB[-favour\fP (\fIduplicate resolution policy\fP)\fB]\fP \fB[-pick\fP (\fIimmediate duplicate resolution\fP)\fB]\fP \fB[-purge\fP pat (\fIdelete bookmarks\fP)\fB]\fP \fB[-purge-mark\fP (\fIpat\fP)\fB]\fP \fB[-d\fP (\fIdump resource file to STDOUT\fP)\fB]\fP \fB[-l\fP (\fIlist available jumps\fP)\fB]\fP \fB[-u\fP (\fIremove last additions\fP)\fB]\fP \fB[--rehash\fP (\fIre-expand portal bookmarks\fP)\fB]\fP \fB[--bu\fP (\fIcreate backup of resource file\fP)\fB]\fP \fB[-bu\fP (\fIcreate backup in \fP)\fB]\fP \fB[--cwd\fP (\fIuse getcwd(3), not pwd(1)\fP)\fB]\fP \fB[--shell-examples\fP (\fIoutput example macros\fP)\fB]\fP .SH DESCRIPTION Apparix combines the properties of the \fIcdargs\fP utility and the CDPATH shell mechanism for fast navigation through the file system\&. It can additionally act as the regular \fIcd\fP command\&. It is especially useful for visiting and documenting both often- and rarely-used locations\&. Apparix enables you to attach marks to locations and jump to those locations by loading the mark\&. Marking, unmarking and jumping are simple operations that are performed in the shell\&. All actions take effect immediately in all shells running\&. By setting up convenient aliases for marking and jumping the file system can be navigated in a fast and intuitive manner\&. The \fBFILES\fP section lists aliases for csh-type shells and functions for bash, including the setup to equip the \fBto\fP function with argument completion in bash\&. This section contains some examples of the most common uses of apparix\&. \fBOPTIONS\fP contains a list of additional options available for listing, pruning, and squashing bookmarks\&. \fBNOTES\fP features a brief discussion of the advantages of apparix over other approaches such as setting up aliases for often visited directories, using symlinks, CDPATH, or a combination of these\&. \fBHISTORY\fP explains the difference between cdargs and apparix\&. The sections \fBduplicate resolution\fP, \fBsubdirectory specification\fP, \fBtab completion\fP, \fBcopying and moving files\fP, \fBlisting bookmarks\fP, and \fBreplacing cd\fP further below are also recommended reading\&. Apparix works in a manner similar to cdargs\&. One usually invokes apparix by using pre-defined aliases\&. Here they will be called \fBbm\fP for bookmark, \fBportal\fP for a CDPATH-style bookmark and \fBto\fP for initiating an apparition (aka jump)\&. These aliases are found below in the \fBFILES\fP section and can also be obtained by issuing .di ZV .in 0 .nf \fC apparix --shell-examples .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR Suppose your user name is \fIeez\fP and your home directory is \fC/home/eez\fP\&. You often visit a directory called \fC/home/eez/cvs/xyz/tfa/faq/zut/bar/foo\fP\&. This is how to create and use a bookmark for foo .di ZV .in 0 .nf \fC /home/eez/cvs/xyz/tfa/faq/zut/bar/foo> \fBbm foo\fP added: foo -> /home/eez/cvs/xyz/tfa/faq/zut/bar/foo /home/eez/cvs/xyz/tfa/faq/zut/bar/foo> \fBcd\fP /home/eez> \fBto foo\fP /home/eez/cvs/xyz/tfa/faq/zut/bar/foo> .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR If one bookmarks a directory by its trailing component as happened in this case, it is not necessary to specify the mark\&. By default apparix will use the trailing component as the mark\&. So .di ZV .in 0 .nf \fC /home/eez/cvs/xyz/tfa/faq/zut/bar/foo> \fBbm\fP added: foo -> /home/eez/cvs/xyz/tfa/faq/zut/bar/foo .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR gives the same result\&. Another scenario is where you have some directory that contains a largish number of subdirectories, all of which you would like to have bookmarked\&. If the subdirectories have distinctive names this can be achieved in one fell swoop by marking the parent directory as a \fIportal\fP\&. This is similar to adding the parent directory to the CDPATH environment variable, except that apparix bookmarks are not part of the cd namespace\&. It is argued in \fBNOTES\fP that this is a good thing\&. Consider this: .di ZV .in 0 .nf \fC /home/cvs/bagger/boemel/mcl/mcl/src> \fBls\fP alien/ CVS/ impala/ Makefile\&.am README shmcx/ attic/ giraffe/ lib/ Makefile\&.in shcl/ shmx/ contrib/ gmon\&.out Makefile mcl/ shmcl/ taurus/ .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR Some of the subdirectories have not-so-distinct names such as \fIcontrib\fP and \fIattic\fP, but they happen to be the directories least visited\&. Issuing: .di ZV .in 0 .nf \fC /home/cvs/bagger/boemel/mcl/mcl/src> \fBportal\fP [apparix] expanded 1 portal to 12 destinations .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR yields all of the subdirectories as destinations bookmarked by the last component of their path name\&. Incidentally, directory names such as \fCCVS\fP can be explicitly excluded from expansion by setting the environment variable \fCAPPARIXEXCLUDE\fP appropriately \- refer to section \fBENVIRONMENT\fP\&. Bookmarks resulting from portal expansion are kept in a separate resource file (see \fBFILES\fP)\&. Portal expansions can be recreated by issuing .di ZV .in 0 .nf \fC apparix --rehash .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR This is useful to reflect a change in the directory naming structure underneath a portal\&. .SH duplicate resolution Apparix allows identical bookmarks to point to different locations\&. When asked to visit such a bookmark it will by default present a list of options\&. The \fB-favour\fP\ \&\fI\fP option can be used to automate resolution\&. \fB\fP is a sequence of single characters, described further below\&. The order in which they are given denote the order in which resolution rules are applied\&. This option is typically used in the definition of the \fBto\fP function/alias or in the bash completion code\&. The \fB-pick\fP\ \&\fI\fP option is used to resolve to a particular directory directly\&. This is useful when you already know where you want to go, and typically used for the \fCnow\fP bookmark in conjunction with the bash \fCwhence\fP function\&. Use \fCwhence now\fP to see an indexed list of now bookmarks\&. It is possible to go to the desired directory by entering the bookmark index\&. It is possible to bypass the selection step by specifying \fCwhence now N\fP\&. Duplicates are allowed because it can be useful to overwrite a bookmark with a new location\&. The old bookmark is kept as a matter of policy\&. Use \fB-sm\fP to explicitly squash duplicates\&. .ZI 2m "l" \fIlevel\fP; prefer paths with fewer components\&. .in -2m .ZI 2m "L" reverse of the above\&. .in -2m .ZI 2m "o" \fIbookmark order\fP; prefer older entries\&. Entries appearing earlier in the file are considered older, but the actual date of creating the bookmark is not stored\&. Refer to \fBediting bookmarks\fP for more information\&. .in -2m .ZI 2m "O" reverse of the above\&. .in -2m .ZI 2m "r" \fIregular first\fP; prefer regular bookmarks over portal expansion\&. .in -2m .ZI 2m "R" reverse of the above\&. .in -2m If there are still ties after the specified rules have been applied apparix will simply take the first matching option\&. This behaviour cannot be further specified as the program uses a non-stable ordering routine\&. It is an absolute prerequisite that \fB-favour\fP is used in the bash completion code\&. Otherwise completion will fail (for a duplicated bookmark) while apparix is waiting for input\&. Refer to the tab completion description below\&. .SH subdirectory specification When jumping (apparating) you can specify an additional subdirectory after the bookmark\&. Apparix will append the subdirectory to the destination\&. This is useful for projects with directory nodes corresponding with versions\&. Assume you have a directory structure such as this: .di ZV .in 0 .nf \fC /x/y/z/OpusMagnum/v1/ /x/y/z/OpusMagnum/v2/ /x/y/z/OpusMagnum/v3/ .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR It is probably easiest to simply bookmark the OpusMagnum directory in some way (say with bookmark \fCom\fP)\&. You can then issue \&'\fCto om v2\fP\&' to jump to \fCOpusMagnum/v2\fP\&. This is more flexible and maintainable than creating bookmarks \fCom1\fP, \fCom2\fP, \fCom3\fP\&. One could add OpusMagnum as a portal, but with generic names such as \fCv1\fP this is not a very extendible approach\&. See also the tab completion description below - it is possible to tab-complete on subdirectories of the apparix jump directory\&. .SH tab completion The bash tab completion code does two things\&. First, it is possible to tab-complete on apparix bookmarks themselves, showing a listing of all available bookmarks (or iterating through them in cyclic mode, depending on your bash settings)\&. Second, once a bookmark has been given tab completion will list or iterate over all the subdirectories of the directory associated with that bookmark\&. Specifying a string after the bookmark will limit tab-completion to directories matching the shell-pattern in string\&. \fIVery\fP useful\&. Be careful to not remove the \fB-favour\fP\ \&\fIlist\fP option from the bash completion code\&. It is necessary to resolve duplicate bookmarks\&. .SH editing bookmarks Apparix appends new bookmarks to the end of the \&.apparixrc file\&. Nothing stops you from editing the file, and this is in fact recommended if for example you need to get rid of a bookmark and neither of \fB-purge\fP, \fB-purge-mark\fP, \fB-sd\fP, \fB-sm\fP fulfills your needs\&. It was an easy design choice not to equip apparix with editor capabilities\&. .SH copying and moving files It is straightforward to copy or move files to locations known by apparix\&. Examples: .di ZV .in 0 .nf \fC BASH and variants cp FOO $(apparix zoem) mv BAR $(apparix zoem doc) mv BAR $(apparix zoem doc)/test CSH and variants cp FOO \&`apparix zoem\&` mv BAR \&`apparix zoem doc\&`/test .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR .SH listing bookmarks Simply issuing apparix gives you a list of bookmarks grouped into three categories, portals, expansions, and bookmarks\&. Use the \fB-d\fP option to dump the resource file to STDOUT exactly as it is\&. This can be useful when you intend to use the \fB-u\fP\ \&\fInum\fP option to remove bookmarks or portals that were most recently added\&. Use \fB-l\fP to list all available jumps without their destinations\&. The jumps are grouped into expansions resulting from portals and regular bookmarks\&. .SH replacing cd With the supplied definition(s) of \fBto\fP, apparix will first see whether the mark is the name of a directory, accessible from the current directory\&. A directory is accessible if it would be a valid argument to cd, so it need not necessarily be a subdirectory of the current directory\&. If the mark is not an accessible directory, apparix will then try to do a lookup of the mark in the bookmark files\&. This behaviour can be inverted to do the lookup first and the current directory thereafter\&. Both modes can be used to make \fBto\fP a drop-in replacement for \fIcd\fP\&. Additionally and again similar to \fIcd\fP, \fC\&'to -\&'\fP will take you to the previous directory, and specifying \fCto\fP without arguments will take you to your home directory\&. The bash completion code acts accordingly, and should transparently complete on both marks and directories\&. .SH OPTIONS For bookmarking and jumping apparix is best invoked by using the aliases (tcsh-variants) or functions (sh/bash) listed in \fBFILES\fP\&. Apparix has a few options that are useful for pruning, squashing and rehasing bookmarks\&. These are best issued by invoking apparix directly\&. If you are interested in marks or destinations matching a certain pattern, simply issue apparix without arguments and pipe it through your program of choice\&. Unary options (those without arguments) usually start with two hyphens except for standardized options such as \fB-h\fP\&. Options that take an argument can be converted to a unary key=value notation, e\&.g\&. \fB-purge-mark\fP\ \&\fBfoo\fP is equivalent to \fB--purge-mark\fP=\fBfoo\fP\&. When invoked without arguments apparix will simply dump its bookmarks\&. .ZI 2m "\fB--add-mark\fP (\fIadd jump bookmark\fP)" \& .br This options expects trailing \fI[mark [destination]]\fP argument(s)\&. Both arguments are optional\&. If a single argument is given it is interpreted as a bookmark name to be mapped to the current directory\&. If two arguments are given the last argument is taken as the target directory\&. If no argument is given apparix will enlist the current directory as a target bookmarked by the trailing component of the directory path\&. .in -2m .ZI 2m "\fB--add-portal\fP (\fIadd portal bookmark\fP)" \& .br This option enlists a directory as a portal and adds all subdirectories as bookmarks\&. The name of the bookmark is simply the name of the subdirectory\&. By default the current directory is added as a portal\&. An optional trailing argument will override this behaviour and instead be interpreted as the portal location\&. .in -2m .ZI 2m "\fB--try-current-first\fP (\fItry current directory before lookup\fP)" \& .br This option is useful in the definition of the \fBto\fP wrapper\&. Before attempting any lookup of the mark, apparix tests whether the supplied mark exists as a subdirectory in the current directory\&. If it does, the mark is simply expanded to itself\&. .in -2m .ZI 2m "\fB--try-current-last\fP (\fItry current directory if lookup fails\fP)" \& .br This option is useful in the definition of the \fBto\fP wrapper\&. If lookup of the mark fails, apparix tests whether the supplied mark exists as a subdirectory in the current directory\&. If it does, the mark is simply expanded to itself\&. .in -2m .ZI 2m "\fB--notify-current\fP (\fInotify if current directory is used\fP)" \& .br This option is useful in the definition of the \fIbf\fP wrapper in conjunction with either \fB--try-current-first\fP or \fB--try-current-last\fP\&. If the mark is found as a subdirectory in the current directory, apparix notifies the user of this fact (on the diagnostic stream)\&. .in -2m .ZI 2m "\fB-sm\fP (\fIsquash repeated marks\fP)" \& .br Apparix will squash bookmarks with mark \fC\fP\&. This is useful when a mark points to a versioned project, and the project is updated to a new version and a new directory\&. Apparix will by default keep the last one occurring in the resource file (corresponding with \fB-favour\fP\ \&\fBO\fP)\&. This option respects the \fB-favour\fP option if given\&. Duplicating an already existing mark can be useful when it identifies a project for which the underlying directory changes every once in a while (e\&.g\&. the project is downloaded from external sources and comes with version information)\&. It is not strictly necessary to squash bookmarks since \fBto\fP functions/macros that are equipped with the \fB-favour\fP option will generally resolve duplicate matches\&. .in -2m .ZI 2m "\fB-sd\fP (\fIsquash repeated destinations\fP)" \& .br All other bookmarks with the same destination as \fC\fP are removed\&. This is useful when a given destination has acquired multiple bookmarks and you decide to settle on a favourite\&. .in -2m .ZI 2m "\fB-lm\fP (\fIlist bookmarks with this mark\fP)" \& .br It lists all bookmarks \fC\fP (noting that it may point to multiple locations)\&. .in -2m .ZI 2m "\fB-ld\fP (\fIlist repeated destinations\fP)" \& .br This lists all bookmarks \fC\fP (noting that it may point to multiple locations) and additionally lists all other bookmarks that share the destination with any of the first bookmarks\&. This allows one to predict the effect of issuing \fCapparix -sd \fP\&. .in -2m .ZI 2m "\fB-purge\fP pat (\fIdelete bookmarks\fP)" \& .br This deletes bookmarks where destination matches \fIpat\fP\&. All deleted bookmarks are printed to STDOUT\&. Thus if you regret deleting a bookmark it is easy to add it back\&. Portal specifications are never affected\&. .in -2m .ZI 2m "\fB-purge-mark\fP (\fIpat\fP)" \& .br This deletes bookmarks where mark matches \fIpat\fP\&. Portal specifications are never affected\&. .in -2m .ZI 2m "\fB-d\fP (\fIdump resource file to STDOUT\fP)" \& .br Dump resource file to STDOUT\&. .in -2m .ZI 2m "\fB-l\fP (\fIlist available jumps\fP)" \& .br List available jumps paragraph-style\&. Portal specifications themselves are excluded, and regular jumps and jumps resulting from portal expansions are listed under different headers\&. .in -2m .ZI 2m "\fB-u\fP (\fIremove last additions\fP)" \& .br Remove last additions\&. Portal specifications and regular jumps are treated alike\&. .in -2m .ZI 2m "\fB--rehash\fP (\fIre-expand portal bookmarks\fP)" \& .br Apparix will reread the resource file and reexpand portal locations\&. Useful if directories have been added, renamed, or removed\&. Refer to section \fBENVIRONMENT\fP for the effect that the environment variable \fCAPPARIXEXCLUDE\fP has on portal expansion\&. .in -2m .ZI 2m "\fB-favour\fP (\fIset duplicate resolution policy\fP)" \& 'in -2m .ZI 2m "\fB-pick\fP (\fIimmediate duplicate resolution\fP)" \& 'in -2m 'in +2m \& .br These options have a section to themselves\&. Refer to \fBduplicate resolution\fP\&. .in -2m .ZI 2m "\fB--cwd\fP (\fIuse getcwd(3), not pwd(1)\fP)" \& .br By default aparix uses the program \fIpwd\fP(1) rather than the system call \fIgetcwd\fP(3)\&. On some systems it was found that the latter results in paths that contain machine-specific mount components\&. Appparix will use \fIgetcwd\fP(3) when \fB--cwd\fP is used\&. .in -2m .ZI 2m "\fB--shell-examples\fP (\fIoutput example macros\fP)" \& .br This outputs example macros\&. They are also listed in the \fBFILES\fP section though\&. .in -2m .ZI 2m "\fB--bu\fP (\fIcreate backup of the resource file\fP)" \& .br This creates the backup file in \&.apparixrc\&.bu\&. .in -2m .ZI 2m "\fB-bu\fP fname (\fIcreate backup of the resource file\fP)" \& .br This creates the backup file in \fIfname\fP\&. Use \fB-d\fP or \fB-bu\fP\ \&\fB-\fP to dump to STDOUT\&. .in -2m .ZI 2m "\fB-h\fP (\fIshow synopsis\fP)" \& 'in -2m .ZI 2m "\fB--apropos\fP (\fIshow synopsis\fP)" \& 'in -2m 'in +2m \& .br print synopsis of all options .in -2m .SH ENVIRONMENT .ZI 2m "APPARIXEXCLUDE" \& .br This variable specifies exclusion behaviour when portals are expanded with the \fC--rehash\fP option\&. It has the following syntax: .di ZV .in 0 .nf \fC <[:,][]>+ .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR That is, a list of names with each name preceded by a colon or a comma\&. A colon indicates that \fC\fP triggers exclusion of directory names for which the trailing component is identical to \fC\fP\&. A comma indicates that \fC\fP triggers exclusion of directory names for which the trailing component contains \fC\fP as a substring\&. Consider: .di ZV .in 0 .nf \fC export APPARIXEXCLUDE=:CVS:lib,tmp # A - example export APPARIXEXCLUDE=, # B - curiosity .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR The first excludes directory names \fCCVS\fP and \fClib\fP and any directory name having \fCtmp\fP as a substring\&. The second example will effectively disable portals, as it speficies the empty string which is a substring of all strings\&. .in -2m .ZI 2m "APPARIXTAG" \& .br This variable, if set, is incorporated into the names of the apparix resource files\&. By default these are \fC\&.apparixrc\fP and \fC\&.apparixexpand\fP\&. When APPARIXTAG is set to \fC\fP they become \fC\&.apparixrc\fP and \fC\&.apparixexpand\fP\&. This can be used e\&.g\&. to maintain different sets of bookmarks on different host machines\&. .in -2m .ZI 2m "APPARIXLOG" \& .br This variable, if set, is interpreted as the name of a log file\&. The log file keeps track of all newly added bookmarks and portals without ever deleting anything, in the same format as the \fC\&.apparixrc\fP file\&. If this variable is not set nothing is tracked\&. .in -2m .ZI 2m "APPARIXPURGE" \& .br This changes the way apparix dumps purged bookmarks to STDOUT\&. By default they are dumped as command lines that will reimport the bookmarks if issued (i\&.e\&. cut and pasted)\&. By setting this variable to 1 purged bookmarks are dumped in the format used in the \fC\&.apparixrc\fP file\&. .in -2m .SH FILES You should use aliases or functions to make apparix really useful\&. Get them from apparix by giving it the --shell-examples option, or from further below\&. Note the fragment that provides \fBto\fP argument completion in bash\&. .ZI 2m "$HOME/\&.apparixrc" \& .br This is the primary resource file\&. There is usually no need to edit it by hand\&. Sometimes it can be useful to edit by hand to remove an unwanted bookmark; refer to \fBediting bookmarks\fP\&. .in -2m .ZI 2m "$HOME/\&.apparixrc\&.bu" \& .br Apparix creates a back-up file whenever it is asked to remove entries from it\&. Refer to \fBediting bookmarks\fP for options inducing removal\&. You can explicitly require a backup to be made by either of \fB--bu\fP or \fB-bu\fP\ \&\fIfname\fP\&. .in -2m .ZI 2m "$HOME/\&.apparixexpand" \& .br This contains bookmarks that are expanded from portals\&. A portal is simply some directory\&. The names of all subdirectories are taken as bookmarks that point to those subdirectories\&. This file can be recreated by issuing .di ZV .in 0 .nf \fC apparix --rehash .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR .in -2m .ZI 2m "$HOME/\&.bashrc" \& 'in -2m .ZI 2m "$HOME/\&.tcshrc" \& 'in -2m .ZI 2m "$HOME/\&.cshrc" \& 'in -2m 'in +2m \& .br Add the code you need to the appropriate rc file\&. The macros and functions below point \fIcd\fP(1) in the right direction\&. .in -2m .di ZV .in 0 .nf \fC BASH-style functions --- function to () { if test "$2"; then cd "$(apparix --try-current-first -favour rOl "$1" "$2" || echo \&.)" elif test "$1"; then if test "$1" == \&'-\&'; then cd - else cd "$(apparix --try-current-first -favour rOl "$1" || echo \&.)" fi else cd $HOME fi } function bm () { if test "$2"; then apparix --add-mark "$1" "$2"; elif test "$1"; then apparix --add-mark "$1"; else apparix --add-mark; fi } function portal () { if test "$1"; then apparix --add-portal "$1"; else apparix --add-portal; fi } # function to generate list of completions from \&.apparixrc function _apparix_aliases () { cur=$2 dir=$3 COMPREPLY=() nullglobsa=$(shopt -p nullglob) shopt -s nullglob if let $(($COMP_CWORD == 1)); then # now cur= (completing on this) and dir=\&'to\&' # Below will not complete on subdirectories\&. swap if so desired\&. # COMPREPLY=( $( cat $HOME/\&.apparix{rc,expand} | grep "j,\&.*$cur\&.*," | cut -f2 -d, ) ) COMPREPLY=( $( (cat $HOME/\&.apparix{rc,expand} | grep "\e and cur= (completing on this) dir=\&`apparix --try-current-first -favour rOl $dir 2>/dev/null\&` || return 0 eval_compreply="COMPREPLY=( $( cd "$dir" \els -d $cur* | while read r do [[ -d "$r" ]] && [[ $r == *$cur* ]] && echo \e"${r// /\e\e }\e" done ) )" eval $eval_compreply fi $nullglobsa return 0 } # command to register the above to expand when the \&'to\&' command\&'s args are # being expanded complete -F _apparix_aliases to --- CSH-style aliases --- # The outcommented alias does not supplant cd, the other one does\&. # alias to \&'cd \&`(apparix -favour rOl \e!* || echo -n \&.)\&`\&' alias to \&'(test "x-" = "x\e!*") && cd - || (test "x" != "x\e!*") && cd \&`(apparix --try-current-first -favour rOl \e!* || echo -n \&.)\&` || cd\&' alias bm \&'apparix --add-mark \e!*\&' alias portal \&'apparix --add-portal \e!*\&' --- .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR More elaborate setups are possible\&. This CSH-style alias: .di ZV .in 0 .nf \fC alias to \&'(test "x" != "x\e!*") && cd \&`(apparix -favour rOl \e!* || echo -n \&.)\&` || apparix -l\&' .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR lists all available jumps if invoked without arguments\&. .SH NOTES Below follow some comments on other approaches to file system navigation\&. \fBHISTORY\fP explains the difference between the venerable \fBcdargs\fP program and \fBapparix\fP\&. CDPATH is only useful in cases where a given directory has subdirectories with distinctive names\&. It does not usually scale well when there are more than a few paths in CDPATH\&. Some people use aliases to jump to often visited directories\&. I was one of them for a period of ten years\&. The fact is, those aliases are cumbersome to create and remove and they clutter up the alias namespace\&. They can clash with executable names when the alias includes the \fIcd\fP part\&. This sometimes prohibits one from assigning the logical bookmark to a given location, especially when one has a lot of source code locations\&. They can clash with directory names when the aliases just expand to the location\&. This again means that sometimes a location cannot be assigned its logical bookmark\&. I have found that setting \fIcd\fP jumps aside in their own namespace improves file system navigation by a large factor\&. It is also possible to create symlinks to often visited files\&. Again, creation and removal of these are cumbersome\&. One could of course create shell functions with a similar interface to apparix or cdargs to handle the symlink lifecycle\&. On Linux Weekly News \fInix\fP suggested to put these symlinks in a single directory and add that directory to CDPATH\&. This is quite a neat trick and effectively creates a bookmark navigation system\&. Still there are problems with the above approach\&. One problem with the symlink approach is that they are a bit awkward to edit\&. One could make a utility to wrap around the problem, but in the end the directory-with-symlinks would functionally be the same as apparix\&'s \fB\&.apparixrc\fP resource file, only more of a kludge\&. Another problem is that symlinks are awkard when traversing the file system\&. They confuse the notion of parent directory and \&'\fCcd \&.\&.\fP\&' mostly does the unexpected\&. Sometimes \&'\fC\&.\&.\fP\&' has a different meaning to \fBcd\fP than it has to another application, as one will trace back symlinks and the other will not\&. Finally, a minor objection is that I find it convenient to have bookmarks in a separate namespace than that of \fIcd\fP(1)\&. Jumps are magical and it is natural to invoke them by a different method\&. This is in fact how apparix acquired its CDPATH behaviour\&. I used CDPATH to jump to a few particular source directories with distinct names that lay deeply hidden in some CVS directory\&. Once I started using apparix however, I would mistakenly issue \fIto\fP rather than \fIcd\fP to jump to those locations\&. My brain classified both types of jump in the same category\&. Apparix (and cdargs) have another use besides jumping, namely annotation\&. Whenever I end up in an esoteric part of the file system and need to make a quick note of the location, I simply bookmark it\&. On SlashDot, that eternal source of wisdom or alternatively the geek wheel of suffering, Clueless Moron offered the following gems\&. .di ZV .in 0 .nf \fC mk() { eval ${1:-MKPWD}=\e"\&`pwd\&`\e"; } rt() { eval cd \e"\e$${1:-MKPWD}\e";pwd; } # type "mk" (as in "mark") and "rt" (as in "return") to mark # a directory and later go back to it\&. # Or give it a name: do "mk foo", and later on "rt foo" .fi \fR .in .di .ne \n(dnu .nf \fC .ZV .fi \fR This of course is a per-session mechanism, but noteworthy for its simplicity\&. I am not sure whether csh-style shells could offer an equivalent\&. A feature shared by apparix and cdargs is that adding a bookmark immediately takes effect in all shells\&. There is no need to source some resource file, as the applications do this every time they are invoked\&. It is fast, do not worry\&. .SH BUGS The resource file parsing code thinks that parentheses are special\&. Also records are currently separated by commas\&. Accordingly, apparix will hitch if a path name contains a parenthesis or a comma\&. .SH AUTHOR Stijn van Dongen\&. .SH THANKS Stefan Kamphausen wrote \fBcdargs\fP, the inspiration for apparix\&. Sitaram Chamarty fixed up some of the existing bash code, and added the tab completion part (basing this on similar code in cdargs)\&. He does not garantuee predictable or even pretty results if there are spaces in the directory names which you attempt to complete\&. \fBAUTHOR\fP would like to submit that spaces in path names are evil, and that the completion code seems to work in their evil presence anyway\&. Just \fIdon\&'t put commas\fP in path names\&. The autotooled build environment was modified from a template written by Joost van Baal\&. Several people suggested to enable apparix to merge accessible directories and marks, but Matias Piipari phrased it the most convincingly\&. .SH HISTORY Apparix was created to optimize a scenario that \fIcdargs\fP does not support very well, namely where the mark (called \fIneedle\fP in cdargs) is always known\&. As additional features apparix supports CDPATH-style behaviour, derived subdirectory specification, and transparent treatment of bookmarks and directories, all integrated with bash tab completion\&. In other respects apparix is a much simpler application\&. \fBcdargs\fP offers menu-based navigation of the file system and the bookmark list, which apparix does not\&.