1\import{pud/man.zmm}
2
3\setx{"year"}{\zinsert{stamp.year}}
4\setx{"month"}{\zinsert{stamp.month}}
5\setx{"day"}{\zinsert{stamp.day}}
6\setx{"tag"}{\zinsert{stamp.tag}}
7\setx{"stamp"}{\zinsert{stamp.stamp}}
8
9\setx{"year"}{\tr{{delete}{[:space:]}}{\"year"}}
10\setx{"month"}{\tr{{delete}{[:space:]}}{\"month"}}
11\setx{"day"}{\tr{{delete}{[:space:]}}{\"day"}}
12\setx{"stamp"}{\tr{{delete}{[:space:]}}{\"stamp"}}
13\setx{"tag"}{\tr{{delete}{[:space:]}}{\"tag"}}
14
15\setx{"tag"}{\"tag", \"stamp"}
16
17\begin{pud::man}{
18
19   {name}{apparix}
20   {html_title}{apparix, augmenting the shell with directory bookmarks}
21   {keywords}{cd, change directory, bookmarks, command line, cdpath, subdirectory, tab completion}
22   {author}{Stijn van Dongen}
23   {section}{1}
24   {synstyle}{long}
25   {defstyle}{long}
26
27   {year}{\"year"}
28   {day}{\"day"}
29   {month}{\"month"}
30   {stamp}{\"stamp"}
31   {tag}{\"tag"}
32}
33
34\${html}{\"pud::man::maketoc"}
35
36\def{apparix}{\bf{apparix}}
37
38\sec{name}{NAME}
39\NAME{apparix}{augmenting cd with bookmarks}
40
41
42\sec{synopsis}{SYNOPSIS}
43
44\par{
45   Apparix allows you to bookmark directories and later jump to them using the mark.
46
47   By default apparix acts as a replacement for \it{cd} and can be used in the
48   same manner, including the special behaviour for \it{cd} without argument
49   and \it{cd}\~\tt{-}.
50
51   It is possible to directly jump to subdirectories of a bookmarked directory.
52
53   The contributed bash completion code facilitates completion both on
54   bookmarks and directories, but can be adjusted to accomodate other
55   preferences.
56
57   }
58
59\par{
60   This manual page suffers from an excess in verbosity due to the many
61   examples, explanations of the bells and whistles, and comparisons with other
62   approaches to bookmarking. The fundamental idea is simply that typing a
63   string of your own choosing takes you to the directory associated with it.
64   Apparix does little more than maintaining a list of keys and values.
65   It obtains directory names and listings, associates
66   path names (values) with bookmarks (keys), and has some facilities for
67   manipulating keys and values. The functions involving apparix
68   (\bf{bm}, \bf{to}, and \bf{portal}) provide the user interface.
69   Other functions, \bf{als} (apparix ls) and \bf{ae} (apparix edit)
70   are discussed on the main apparix page \httpref{http://micans.org/apparix}.
71   }
72
73\sec{gs}{GETTING STARTED}
74\par{
75   Install apparix. This should be as easy as \v{./configure --prefix=$HOME/local && make && make install},
76   or perhaps a pre-packaged apparix is available for your system.
77
78   Then get hold of the \bf{to}, \bf{bm} and \bf{portal} shell handles. These
79   are either aliases or functions depending on your shell. Currently csh-style
80   shells and bash are supported.
81   Get the ones you need preferably from
82   \httpref{http://micans.org/apparix/#shell}.  For a more limited set of
83   commands either visit the \secref{files} section, or issue \v{apparix
84   --shell-examples}. Activate them by simply pasting them in a shell or adding
85   them to the appropriate resource file, e.g.  \v{$HOME/.cshrc} or
86   \v{$HOME/.bashrc} (do not forget to \it{source} the resource file). The
87   handles \bf{to}, \bf{bm} and \bf{portal} can of course be changed to any
88   name desired. With these preliminaries, the following is a mock-up shell
89   navigation session.
90
91   }
92
93\verbatim{\:/
94   > \bf{pwd}
95   /home/eez/cvs/xyz/tfa/faq/zut/bar/foo
96   > \bf{ls}
97   src/ doc/ CVS/ bin/
98   > \bf{bm xkr}       # bookmark as xkr (funny name though)
99   > \bf{bm}           # bookmark as foo (trailing component is default)
100(later)
101   > \bf{to xkr}       # cd to /home/eez/cvs/xyz/tfa/faq/zut/bar/foo
102(alternatively)
103   > \bf{to xkr src}   # cd to /home/eez/cvs/xyz/tfa/faq/zut/bar/foo/src
104(alternatively)
105   > \bf{to foo}       # cd to /home/eez/cvs/xyz/tfa/faq/zut/bar/foo
106
107(later)
108   > \bf{ls}
109   aap pyu/ qua tim/ zut/
110   > \bf{pwd}
111   /home/eez/another/branch/deep/down/under
112   > \bf{portal}       # bookmark as portal, imports tim zut pyu bookmarks
113   added flock of 3 in portal /home/eez/another/branch/deep/down/under
114
115(later)
116   > \bf{to zut}       # cd to /home/eez/another/branch/deep/down/under/zut
117
118(later)
119   > \bf{apparix}   # show all bookmarks
120   --- portals
121   e              /home/eez/another/branch/deep/down/under
122   --- expansions
123   j pyu          /home/eez/another/branch/deep/down/under/pyu
124   j tim          /home/eez/another/branch/deep/down/under/tim
125   j zut          /home/eez/another/branch/deep/down/under/zut
126   --- bookmarks
127   j xkr          /home/eez/cvs/xyz/tfa/faq/zut/bar/foo
128   j foo          /home/eez/cvs/xyz/tfa/faq/zut/bar/foo}
129
130
131\car{
132   In the last example apparix simply shows all its bookmarks.  The first batch
133   shows portals. The second batch shows secondary bookmarks expanded from
134   portals. The third batch shows all regular bookmarks.
135
136   }
137
138
139\par{
140   In the default definitions of \bf{to} it falls back to regular \it{cd}
141   behaviour in case a mark is not found.  This is done by instructing apparix
142   to check whether the mark exists as the name of a directory.  It is possible
143   to do this either before or after bookmark lookup, or not at all. By default
144   the bash completion code takes into account both bookmarks and directories.
145
146   }
147
148
149\par{
150   Apparix also allows subdirectory specification of bookmarked locations. If
151   this is combined with the bash completion code it yields a powerful way of
152   navigating container directories, i.e. directories that contain a large
153   number of subdirectories.  Refer to the \secref{sub} section.
154
155   }
156
157\cpar{Further options}{
158   \synoptopt{--add-mark}{add jump bookmark}
159   \synoptopt{--add-portal}{add portal bookmark}
160   \synoptopt{-sm}{<mark>}{squash repeated marks}
161   \synoptopt{-sd}{<mark>}{squash repeated destinations}
162   \synoptopt{-lm}{<mark>}{list bookmarks with this mark}
163   \synoptopt{-ld}{<mark>}{list destinations with mark indirection}
164   \synoptopt{-favour}{<list>}{duplicate resolution policy}
165   \synoptopt{-pick}{<num>}{immediate duplicate resolution}
166   \synoptopt{-purge}{pat}{delete bookmarks}
167   \synoptopt{-purge-mark}{pat}
168   \synoptopt{-d}{dump resource file to STDOUT}
169   \synoptopt{-l}{list available jumps}
170   \synoptopt{-u}{<num>}{remove last <num> additions}
171   \synoptopt{--rehash}{re-expand portal bookmarks}
172   \synoptopt{--bu}{create backup of resource file}
173   \synoptopt{-bu}{<fname>}{create backup in <fname>}
174   \synoptopt{--cwd}{use getcwd(3), not pwd(1)}
175   \synoptopt{--shell-examples}{output example macros}
176}
177
178
179\sec{description}{DESCRIPTION}
180
181\par{
182   Apparix combines the properties of the
183   \aref{http://www.skamphausen.de/cgi-bin/ska/CDargs}{cdargs} utility and the
184   CDPATH shell mechanism for fast navigation through the file system. It can
185   additionally act as the regular \it{cd} command. It is especially useful for
186   visiting and documenting both often- and rarely-used locations.  Apparix
187   enables you to attach marks to locations and jump to those locations by
188   loading the mark. Marking, unmarking and jumping are simple operations that
189   are performed in the shell. All actions take effect immediately in all
190   shells running.  By setting up convenient aliases for marking and jumping
191   the file system can be navigated in a fast and intuitive manner.  The
192   \secref{files} section lists aliases for csh-type shells and functions for
193   bash, including the setup to equip the \bf{to} function with argument
194   completion in bash.
195
196   }
197
198\par{
199   This section contains some examples of the most common uses
200   of apparix.
201   \secref{options} contains a list of additional options available
202   for listing, pruning, and squashing bookmarks.}
203
204\par{
205   \secref{notes} features a brief discussion of the advantages
206   of apparix over other approaches such as setting up aliases for
207   often visited directories, using symlinks, CDPATH, or a combination
208   of these. \secref{history} explains the difference between
209   cdargs and apparix.
210   The sections \secref{dup}, \secref{sub}, \secref{tab},
211   \secref{mov}, \secref{list}, and \secref{cd}
212   further below are also recommended reading.}
213
214\par{
215   Apparix works in a manner similar to cdargs. One usually invokes
216   apparix by using pre-defined aliases. Here they will be called \bf{bm} for
217   bookmark, \bf{portal} for a CDPATH-style bookmark and \bf{to} for initiating
218   an apparition (aka jump).
219   These aliases are found below in the \secref{files}
220   section and can also be obtained by issuing}
221
222\verbatim{apparix --shell-examples}
223
224\par{
225   Suppose your user name is \it{eez} and your home directory is \v{/home/eez}.
226   You often visit a directory called
227   \v{/home/eez/cvs/xyz/tfa/faq/zut/bar/foo}.
228   This is how to create and use a bookmark for foo}
229
230\verbatim{\:/
231/home/eez/cvs/xyz/tfa/faq/zut/bar/foo> \bf{bm foo}
232added: foo -> /home/eez/cvs/xyz/tfa/faq/zut/bar/foo
233/home/eez/cvs/xyz/tfa/faq/zut/bar/foo> \bf{cd}
234/home/eez> \bf{to foo}
235/home/eez/cvs/xyz/tfa/faq/zut/bar/foo>}
236
237\car{
238   If one bookmarks a directory by its trailing component as happened in
239   this case, it is not necessary to specify the mark. By default apparix
240   will use the trailing component as the mark. So}
241
242\verbatim{\:/
243/home/eez/cvs/xyz/tfa/faq/zut/bar/foo> \bf{bm}
244added: foo -> /home/eez/cvs/xyz/tfa/faq/zut/bar/foo}
245
246\car{gives the same result.}
247
248\par{
249   Another scenario is where you have some directory that contains a largish
250   number of subdirectories, all of which you would like to have bookmarked.
251   If the subdirectories have distinctive names this can be achieved in
252   one fell swoop by marking the parent directory as a \it{portal}. This is
253   similar to adding the parent directory to the CDPATH environment variable,
254   except that apparix bookmarks are not part of the cd namespace. It is
255   argued in \secref{notes} that this is a good thing.
256   Consider this:}
257
258\verbatim{\:/
259/home/cvs/bagger/boemel/mcl/mcl/src> \bf{ls}
260alien/       CVS/         impala/      Makefile.am  README       shmcx/
261attic/       giraffe/     lib/         Makefile.in  shcl/        shmx/
262contrib/     gmon.out     Makefile     mcl/         shmcl/       taurus/}
263
264\car{
265   Some of the subdirectories have not-so-distinct names such as \it{contrib} and
266   \it{attic}, but they happen to be the directories least visited.
267   Issuing:}
268
269\verbatim{\:/
270/home/cvs/bagger/boemel/mcl/mcl/src> \bf{portal}
271[apparix] expanded 1 portal to 12 destinations}
272
273\car{
274   yields all of the subdirectories as destinations bookmarked by the last
275   component of their path name.
276   Incidentally, directory names such as \v{CVS} can be explicitly excluded
277   from expansion by setting the environment variable \v{APPARIXEXCLUDE}
278   appropriately \- refer to section \secref{environment}.
279   }
280
281\par{
282   Bookmarks resulting from portal expansion are kept in a separate
283   resource file (see \secref{files}). Portal expansions can be recreated
284   by issuing}
285
286\verbatim{apparix --rehash}
287
288\car{
289   This is useful to reflect a change in the directory naming structure
290   underneath a portal.}
291
292\sec{dup}{duplicate resolution}
293
294\par{
295   Apparix allows identical bookmarks to point to different locations.
296   When asked to visit such a bookmark it will by default
297   present a list of options.}
298
299\par{
300   The \genoptref{-favour}{<list>} option can be used to automate
301   resolution. \usearg{<list>} is a sequence of single characters,
302   described further below.
303   The order in which they are given denote the order in which
304   resolution rules are applied. This option is typically used
305   in the definition of the \bf{to} function/alias or
306   in the bash completion code.}
307
308\par{
309   The \genoptref{-pick}{<num>} option is used to resolve to a particular
310   directory directly. This is useful when you already know where you want to
311   go, and typically used for the \v{now} bookmark in conjunction with the bash
312   \v{whence} function. Use \v{whence now} to see an indexed list of now
313   bookmarks. It is possible to go to the desired directory by entering the
314   bookmark index. It is possible to bypass the selection step by specifying
315   \v{whence now N}.
316   }
317
318\par{
319   Duplicates are allowed because it can be useful to overwrite a bookmark with
320   a new location. The old bookmark is kept as a matter of policy. Use
321   \genoptref{-sm} to explicitly squash duplicates.
322   }
323
324\begin{itemize}{
325   {flow}{compact}
326   {interitem}{1}
327}
328\item{l}
329\car{
330   \it{level}; prefer paths with fewer components.}
331
332\item{L}
333\car{
334   reverse of the above.}
335
336\item{o}
337\car{
338   \it{bookmark order}; prefer older entries.
339   Entries appearing earlier in the file are considered older,
340   but the actual date of creating the bookmark is not stored.
341   Refer to \secref{edit} for more information.}
342
343\item{O}
344\car{
345   reverse of the above.}
346
347\item{r}
348\car{
349   \it{regular first}; prefer regular bookmarks over portal expansion.}
350
351\item{R}
352\car{
353   reverse of the above.}
354
355\end{itemize}
356
357\par{
358   If there are still ties after the specified rules have
359   been applied apparix will simply take the first matching
360   option. This behaviour cannot be further specified
361   as the program uses a non-stable ordering routine.}
362
363\par{
364   It is an absolute prerequisite that \genoptref{-favour} is used in the bash
365   completion code. Otherwise completion will fail (for a duplicated bookmark)
366   while apparix is waiting for input. Refer to the tab completion description
367   below.}
368
369\sec{sub}{subdirectory specification}
370
371\par{
372   When jumping (apparating) you can specify an additional subdirectory
373   after the bookmark. Apparix will append the subdirectory to
374   the destination.}
375
376\par{
377   This is useful for projects with directory nodes corresponding
378   with versions. Assume you have a directory structure such as this:}
379
380\verbatim{\:/
381   /x/y/z/OpusMagnum/v1/
382   /x/y/z/OpusMagnum/v2/
383   /x/y/z/OpusMagnum/v3/}
384
385\par{
386   It is probably easiest to simply bookmark the OpusMagnum directory
387   in some way (say with bookmark \v{om}). You can then issue
388   \vq{to om v2} to jump to \v{OpusMagnum/v2}. This is more flexible
389   and maintainable than creating bookmarks \v{om1}, \v{om2}, \v{om3}.
390   One could add OpusMagnum as a portal, but with generic names such
391   as \v{v1} this is not a very extendible approach.}
392
393
394\par{
395   See also the tab completion description below - it is possible
396   to tab-complete on subdirectories of the apparix jump directory.}
397
398
399\sec{tab}{tab completion}
400
401\par{
402   The bash tab completion code does two things. First, it is possible to
403   tab-complete on apparix bookmarks themselves, showing a listing of all
404   available bookmarks (or iterating through them in cyclic mode, depending on
405   your bash settings). Second, once a bookmark has been given tab completion
406   will list or iterate over all the subdirectories of the directory associated
407   with that bookmark.  Specifying a string after the bookmark will limit
408   tab-completion to directories matching the shell-pattern in string.
409   \it{Very} useful.}
410
411\par{
412   Be careful to not remove the \genoptref{-favour}{list} option
413   from the bash completion code. It is necessary to resolve
414   duplicate bookmarks.
415}
416
417\sec{edit}{editing bookmarks}
418
419\car{
420   Apparix appends new bookmarks to the end of the .apparixrc file. Nothing
421   stops you from editing the file, and this is in fact recommended if for
422   example you need to get rid of a bookmark and neither of \genoptref{-purge},
423   \genoptref{-purge-mark}, \genoptref{-sd},
424   \genoptref{-sm} fulfills your needs.  It was an easy design choice
425   not to equip apparix with editor capabilities.}
426
427\sec{mov}{copying and moving files}
428
429\par{
430   It is straightforward to copy or move files to locations known
431   by apparix. Examples:}
432
433\verbatim{BASH and variants
434   cp FOO $(apparix zoem)
435   mv BAR $(apparix zoem doc)
436   mv BAR $(apparix zoem doc)/test
437
438CSH and variants
439   cp FOO `apparix zoem`
440   mv BAR `apparix zoem doc`/test}
441
442
443\sec{list}{listing bookmarks}
444
445\par{
446   Simply issuing apparix gives you a list of bookmarks grouped into three
447   categories, portals, expansions, and bookmarks.  Use the \genoptref{-d} option
448   to dump the resource file to STDOUT exactly as it is. This can be useful
449   when you intend to use the \genoptref{-u}{num} option to remove bookmarks or
450   portals that were most recently added.}
451
452\par{
453   Use \genoptref{-l} to list all available jumps without their destinations.
454   The jumps are grouped into expansions resulting from portals and
455   regular bookmarks.}
456
457
458\: \car{
459\:    Apparix currently uses \it{getcwd}(3) to obtain the path name
460\:    of the current directory. On some machines this may include
461\:    funny mount components, e.g.
462\: }
463\:
464\: \verbatim{\:/
465\: \bf{/.automount/eek/root}/home/eez/cvs/xyz/tfa/faq/zut/bar/foo}
466\:
467\: \car{
468\:    Until apparix obtains a
469\: }
470
471
472\sec{cd}{replacing cd}
473
474\par{
475   With the supplied definition(s) of \bf{to}, apparix will first see whether
476   the mark is the name of a directory, accessible from the current directory.
477   A directory is accessible if it would be a valid argument to cd, so it need
478   not necessarily be a subdirectory of the current directory.  If the mark is
479   not an accessible directory, apparix will then try to do a lookup of the
480   mark in the bookmark files.  This behaviour can be inverted to do the lookup
481   first and the current directory thereafter. Both modes can be used to make
482   \bf{to} a drop-in replacement for \it{cd}.  Additionally and again similar
483   to \it{cd}, \tt{'to -'} will take you to the previous directory, and
484   specifying \tt{to} without arguments will take you to your home directory.
485
486   }
487
488\par{
489   The bash completion code acts accordingly, and should transparently
490   complete on both marks and directories.
491   }
492
493\sec{options}{OPTIONS}
494
495\par{
496   For bookmarking and jumping apparix is best invoked by using the aliases
497   (tcsh-variants) or functions (sh/bash) listed in \secref{files}.
498   Apparix has a few options that are useful for pruning, squashing and
499   rehasing bookmarks. These are best issued by invoking apparix directly.}
500
501\par{
502   If you are interested in marks or destinations matching a certain pattern,
503   simply issue apparix without arguments and pipe it through
504   your program of choice.}
505
506\par{
507   Unary options (those without arguments) usually start with two hyphens
508   except for standardized options such as \genoptref{-h}.
509   Options that take an argument can be converted to a unary key=value notation,
510   e.g. \useopt{-purge-mark}{foo} is equivalent to \usekvp{--purge-mark}{foo}.}
511
512\par{
513   When invoked without arguments apparix will simply dump its bookmarks.}
514
515\begin{itemize}{
516   {flow}{cascade}
517   {interitem}{1}
518}
519\item{\defopt{--add-mark}{add jump bookmark}}
520\car{
521   This options expects trailing \it{[mark [destination]]} argument(s).
522   Both arguments are optional. If a single argument is given it
523   is interpreted as a bookmark name to be mapped to the current directory.
524   If two arguments are given the last argument is taken  as the
525   target directory. If no argument is given apparix will enlist
526   the current directory as a target bookmarked by the trailing component
527   of the directory path.}
528
529\item{\defopt{--add-portal}{add portal bookmark}}
530\car{
531   This option enlists a directory as a portal and adds all subdirectories
532   as bookmarks. The name of the bookmark is simply the name of the
533   subdirectory. By default the current directory is added as a portal.
534   An optional trailing argument will override this behaviour and
535   instead be interpreted as the portal location.}
536
537
538\item{\defopt{--try-current-first}{try current directory before lookup}}
539\car{
540   This option is useful in the definition of the \bf{to} wrapper.  Before
541   attempting any lookup of the mark, apparix tests whether the supplied mark
542   exists as a subdirectory in the current directory. If it does,
543   the mark is simply expanded to itself.
544   }
545
546
547\item{\defopt{--try-current-last}{try current directory if lookup fails}}
548\car{
549   This option is useful in the definition of the \bf{to} wrapper. If
550   lookup of the mark fails, apparix tests whether the supplied mark
551   exists as a subdirectory in the current directory. If it does,
552   the mark is simply expanded to itself.
553   }
554
555
556\item{\defopt{--notify-current}{notify if current directory is used}}
557\car{
558   This option is useful in the definition of the \it{bf} wrapper
559   in conjunction with either \genopt{--try-current-first}
560   or \genopt{--try-current-last}.
561   If the mark is found as a subdirectory in the current directory,
562   apparix notifies the user of this fact (on the diagnostic stream).
563   }
564
565
566\item{\defopt{-sm}{<mar>}{squash repeated marks}}
567\car{
568   Apparix will squash bookmarks with mark \v{<mark>}.
569   This is useful when a mark points to a versioned project, and the
570   project is updated to a new version and a new directory.}
571
572\par{
573   Apparix will by default keep the last one occurring in the resource
574   file (corresponding with \useopt{-favour}{O}).  This option respects the
575   \genoptref{-favour} option if given.  Duplicating an already existing mark
576   can be useful when it identifies a project for which the underlying
577   directory changes every once in a while (e.g. the project is downloaded from
578   external sources and comes with version information). It is not strictly
579   necessary to squash bookmarks since \bf{to} functions/macros that are
580   equipped with the \genoptref{-favour} option will generally resolve
581   duplicate matches.
582   }
583
584\item{\defopt{-sd}{<mark>}{squash repeated destinations}}
585\car{
586   All other bookmarks with the same destination as \v{<mark>} are removed.
587   This is useful when a given destination has acquired multiple
588   bookmarks and you decide to settle on a favourite.
589   }
590
591\item{\defopt{-lm}{<mark>}{list bookmarks with this mark}}
592\car{
593   It lists all bookmarks \v{<mark>} (noting that it may point to
594   multiple locations).
595   }
596
597\item{\defopt{-ld}{<mark>}{list repeated destinations}}
598\car{
599   This lists all bookmarks \v{<mark>} (noting that it may point to
600   multiple locations) and additionally lists all other bookmarks that share
601   the destination with any of the first bookmarks.  This allows one to predict
602   the effect of issuing \v{apparix -sd <mark>}.
603   }
604
605\item{\defopt{-purge}{pat}{delete bookmarks}}
606\car{
607   This deletes bookmarks where destination matches \genarg{pat}.
608   All deleted bookmarks are printed to STDOUT. Thus if you regret
609   deleting a bookmark it is easy to add it back. Portal specifications
610   are never affected.}
611
612\item{\defopt{-purge-mark}{pat}}
613\car{
614   This deletes bookmarks where mark matches \genarg{pat}.
615   Portal specifications are never affected.}
616
617\item{\defopt{-d}{dump resource file to STDOUT}}
618\car{
619   Dump resource file to STDOUT.}
620
621\item{\defopt{-l}{list available jumps}}
622\car{
623   List available jumps paragraph-style. Portal specifications themselves
624   are excluded, and regular jumps and jumps resulting from portal expansions
625   are listed under different headers.}
626
627\item{\defopt{-u}{<num>}{remove last <num> additions}}
628\car{
629   Remove last <num> additions. Portal specifications and regular
630   jumps are treated alike.}
631
632\item{\defopt{--rehash}{re-expand portal bookmarks}}
633\car{
634   Apparix will reread the resource file and reexpand portal
635   locations. Useful if directories have been added, renamed,
636   or removed. Refer to section \secref{environment} for  the effect
637   that the environment variable \v{APPARIXEXCLUDE} has on portal expansion.}
638
639\items{
640   {\defopt{-favour}{<list>}{set duplicate resolution policy}}
641   {\defopt{-pick}{<num>}{immediate duplicate resolution}}
642}
643\car{
644   These options have a section to themselves. Refer to \secref{dup}.}
645
646\item{\defopt{--cwd}{use getcwd(3), not pwd(1)}}
647\car{
648   By default aparix uses the program \it{pwd}(1) rather than
649   the system call \it{getcwd}(3). On some systems it was found
650   that the latter results in paths that contain machine-specific
651   mount components.
652   Appparix will use \it{getcwd}(3) when \genoptref{--cwd} is used.}
653
654\item{\defopt{--shell-examples}{output example macros}}
655\car{
656   This outputs example macros. They are also listed in the
657   \secref{files} section though.}
658
659\item{\defopt{--bu}{create backup of the resource file}}
660\car{
661   This creates the backup file in .apparixrc.bu.}
662
663\item{\defopt{-bu}{fname}{create backup of the resource file}}
664\car{
665   This creates the backup file in \genarg{fname}. Use
666   \genoptref{-d} or \useopt{-bu}{-} to dump to STDOUT.}
667
668\items{
669   {\defopt{-h}{show synopsis}}
670   {\defopt{--apropos}{show synopsis}}
671}
672\car{
673   print synopsis of all options}
674
675\end{itemize}
676
677
678\sec{environment}{ENVIRONMENT}
679
680\'begin{itemize}{
681   {flow}{cascade}
682   {interitem}{1}
683}
684\item{APPARIXEXCLUDE}
685\car{
686   This variable specifies exclusion behaviour
687   when portals are expanded with the \v{--rehash} option.
688   It has the following syntax:
689   }
690
691\verbatim{\:/
692   <[:,][<string>]>+}
693
694\car{
695   That is, a list of names with each name preceded by a colon or a comma.
696   A colon indicates that \v{<string>} triggers exclusion of directory names
697   for which the trailing component is identical to \v{<string>}.
698   A comma indicates that \v{<string>} triggers exclusion of directory names
699   for which the trailing component contains \v{<string>} as a substring.
700   Consider:
701   }
702
703\verbatim{\:/
704   export APPARIXEXCLUDE=:CVS:lib,tmp        # A - example
705   export APPARIXEXCLUDE=,                   # B - curiosity}
706
707\car{
708   The first excludes directory names \v{CVS} and \v{lib} and any directory
709   name having \v{tmp} as a substring.
710   The second example will effectively disable portals,
711   as it speficies the empty string which is a substring of all strings.
712   }
713
714
715\item{APPARIXTAG}
716\car{
717   This variable, if set, is incorporated into the names of the
718   apparix resource files. By default these are \v{.apparixrc} and \v{.apparixexpand}.
719   When APPARIXTAG is set to \v{<tag>} they become \v{.<tag>apparixrc} and
720   \v{.<tag>apparixexpand}.
721
722   This can be used e.g. to maintain different sets of bookmarks on different
723   host machines.
724   }
725
726
727\item{APPARIXLOG}
728\car{
729   This variable, if set, is interpreted as the name of a log file.
730   The log file keeps track of all newly added bookmarks and
731   portals without ever deleting anything, in the same format
732   as the \v{.apparixrc} file. If this variable is not set
733   nothing is tracked.
734   }
735
736
737\item{APPARIXPURGE}
738\car{
739   This changes the way apparix dumps purged bookmarks to STDOUT.
740   By default they are dumped as command lines that will reimport
741   the bookmarks if issued (i.e. cut and pasted).
742   By setting this variable to 1 purged bookmarks are dumped
743   in the format used in the \v{.apparixrc} file.
744   }
745
746\end{itemize}
747
748\sec{files}{FILES}
749
750\par{
751   You should use aliases or functions to make apparix really useful.
752   Get them from apparix by giving it the --shell-examples option,
753   or from further below.
754   Note the fragment that provides \bf{to} argument completion in bash.
755}
756
757\begin{itemize}{
758   {flow}{cascade}
759   {interitem}{1}
760}
761\item{$HOME/.apparixrc}
762\car{This is the primary resource file. There is usually no
763need to edit it by hand. Sometimes it can be useful to edit
764by hand to remove an unwanted bookmark; refer to \secref{edit}.}
765
766\item{$HOME/.apparixrc.bu}
767\car{
768   Apparix creates a back-up file whenever it is asked to
769   remove entries from it. Refer
770   to \secref{edit} for options inducing removal.
771   You can explicitly require a backup to be made by
772   either of \genoptref{--bu} or \genoptref{-bu}{fname}.}
773
774\item{$HOME/.apparixexpand}
775\car{
776   This contains bookmarks that are expanded from portals.
777   A portal is simply some directory. The names of all subdirectories
778   are taken as bookmarks that point to those subdirectories.
779   This file can be recreated by issuing}
780
781\verbatim{apparix --rehash}
782
783\items{{$HOME/.bashrc}
784   {$HOME/.tcshrc}
785   {$HOME/.cshrc}
786}
787\car{
788   Add the code you need to the appropriate rc file.  The macros and functions
789   below point \it{cd}(1) in the right direction.}
790
791\end{itemize}
792
793\setx{"examples"}{\system{../src/apparix}{{--shell-examples}}}
794
795\apply{_#1{\!{\verbatim{\1}}}}{{\"examples"}}
796
797\par{More elaborate setups are possible. This CSH-style alias:}
798
799\verbatim{alias to '(test "x" !=  "x\\!*") && cd `(apparix -favour rOl \\!* || echo -n .)` || apparix -l'}
800
801\par{lists all available jumps if invoked without arguments.}
802
803
804\sec{notes}{NOTES}
805\par{
806   Below follow some comments on other approaches to file system navigation.
807   \secref{history} explains the difference between the venerable \bf{cdargs}
808   program and \bf{apparix}.
809}
810
811\par{
812   CDPATH is only useful in cases where a given directory has subdirectories
813   with distinctive names. It does not usually scale well when there are
814   more than a few paths in CDPATH.
815}
816
817\par{
818   Some people use aliases to jump to often visited directories.
819   I was one of them for a period of ten years. The fact is,
820   those aliases are cumbersome to create and remove and they
821   clutter up the alias namespace. They can clash with
822   executable names when the alias includes the \it{cd} part. This sometimes
823   prohibits one from assigning the logical bookmark to a given
824   location, especially when one has a lot of source code locations.
825   They can clash with directory names when
826   the aliases just expand to the location. This again means that
827   sometimes a location cannot be assigned its logical bookmark.
828   I have found that setting \it{cd} jumps aside in their own namespace
829   improves file system navigation by a large factor.
830}
831
832\par{
833   It is also possible to create symlinks to often
834   visited files. Again, creation and removal of these are cumbersome.
835   One could of course create shell functions with a similar interface
836   to apparix or cdargs to handle the symlink lifecycle.
837   On Linux Weekly News \it{nix} suggested to put these symlinks
838   in a single directory and add that directory to CDPATH.
839   This is quite a neat trick and effectively creates a bookmark
840   navigation system.
841}
842
843\par{
844   Still there are problems with the above approach.
845
846   One problem with the symlink approach is that they are a bit
847   awkward to edit. One could make a utility to wrap around the problem,
848   but in the end the directory-with-symlinks would
849   functionally be the same as apparix's \bf{.apparixrc} resource file,
850   only more of a kludge.
851
852   Another problem is that symlinks are awkard when traversing
853   the file system. They confuse the notion of parent directory
854   and '\v{cd ..}' mostly does the unexpected. Sometimes '\v{..}'
855   has a different meaning to \bf{cd} than it has to another application,
856   as one will trace back symlinks and the other will not.
857
858   Finally, a minor objection
859   is that I find it convenient to have bookmarks in a separate
860   namespace than that of \it{cd}(1). Jumps are magical and it is
861   natural to invoke them by a different method. This is in fact
862   how apparix acquired its CDPATH behaviour. I used CDPATH to
863   jump to a few particular source directories with distinct names
864   that lay deeply hidden in some CVS directory. Once I started using
865   apparix however, I would mistakenly issue \it{to} rather than \it{cd}
866   to jump to those locations. My brain classified both types of jump
867   in the same category.
868}
869
870\par{
871   Apparix (and cdargs) have another use besides jumping, namely
872   annotation. Whenever I end up in an esoteric part of the file system and
873   need to make a quick note of the location, I simply bookmark  it.
874}
875
876\par{
877   On SlashDot, that eternal source of wisdom or alternatively
878   the geek wheel of suffering, Clueless Moron offered the following gems.}
879
880\verbatim{\:/
881   mk() { eval ${1:-MKPWD}=\\"`pwd`\\"; }
882   rt() { eval cd \\"\\$${1:-MKPWD}\\";pwd; }
883
884   # type "mk" (as in "mark") and "rt" (as in "return") to mark
885   # a directory and later go back to it.
886   # Or give it a name: do "mk foo", and later on "rt foo"}
887
888\par{
889   This of course is a per-session mechanism, but noteworthy
890   for its simplicity. I am not sure whether csh-style shells
891   could offer an equivalent.}
892
893\par{
894   A feature shared by apparix and cdargs is that adding a bookmark
895   immediately takes effect in all shells. There is no need to
896   source some resource file, as the applications do this everytime
897   they are invoked. It is fast, do not worry.
898}
899
900
901\""{
902
903At LWN nix writes:
904At work I am stuck with ksh, which doesn't have pushd or popd. Solution:
905
906function pushd
907 {
908  PWDSTACK=${PWD}:${PWDSTACK}
909  cd $1
910 }
911
912function popd
913 {
914  cd $(echo ${PWDSTACK:-${PWD}} | cut -d: -f 1)
915  PWDSTACK=$(echo ${PWDSTACK} | cut -s -d: -f 2-)
916 }
917
918function dirs
919 {
920  echo $PWDSTACK | tr ":" "\\n" | sed '/^$/d'
921 }
922
923(warning: this code was written ten years ago when I barely knew shell
924scripting and not touched since then; it has notable problems, trivially fixed,
925with directories with names starting with minus signs).
926
927}
928
929
930
931\sec{bugs}{BUGS}
932
933\car{
934   The resource file parsing code thinks that parentheses are special.
935   Also records are currently separated by commas.  Accordingly, apparix will
936   hitch if a path name contains a parenthesis or a comma.}
937
938\sec{author}{AUTHOR}
939\car{
940   Stijn van Dongen.}
941
942\sec{thanks}{THANKS}
943
944\par{
945   Stefan Kamphausen wrote \bf{cdargs}, the inspiration for apparix.}
946
947\par{
948   Sitaram Chamarty fixed up some of the existing bash code, and added the tab
949   completion part (basing this on similar code in cdargs).  He does not
950   garantuee predictable or even pretty results if there are spaces in the
951   directory names which you attempt to complete.  \secref{author} would like
952   to submit that spaces in path names are evil, and that the completion code
953   seems to work in their evil presence anyway. Just \iref{bugs}{don't put
954   commas} in path names.
955
956   }
957
958\par{
959   The autotooled build environment was modified from a template written
960   by Joost van Baal.
961
962   }
963
964
965\par{
966   Several people suggested to enable apparix to merge accessible directories
967   and marks, but Matias Piipari phrased it the most convincingly.
968
969   }
970
971
972\sec{history}{HISTORY}
973\par{
974   Apparix was created to optimize a scenario that
975   \aref{http://www.skamphausen.de/cgi-bin/ska/CDargs}{cdargs} does not support
976   very well, namely where the mark (called \it{needle} in cdargs) is always
977   known. As additional features apparix supports CDPATH-style behaviour,
978   derived subdirectory specification, and transparent treatment of bookmarks
979   and directories, all integrated with bash tab completion. In other respects
980   apparix is a much simpler application.  \bf{cdargs} offers menu-based
981   navigation of the file system and the bookmark list, which apparix does not.
982
983   }
984
985\end{pud::man}
986
987