As always, I forgot to reply-to-all. Copying the list in case the function might be useful to other people.
(I'm not using any of these ways myself because as Philip says fish's history lookup works well without bookmarking). ---------- Forwarded message ---------- From: Beni Cherniavsky <[email protected]> Date: 2009/10/15 Subject: Re: [Fish-users] Bookmarking directories a la IPython? To: the jimmybot <[email protected]> 2009/10/15 the jimmybot <[email protected]>: > > Second, my question: There is an enhanced "shell" or interpreter for the > Python programming language called IPython. It is interesting, it shares > some similarities to fish in that it provides by default very nice > completions and easy access to documentation and source, among other > features. In addition, it has a very nifty bookmarking feature for creating > shortcuts to directories that you use often. You can take a look at the > syntax for bookmarking here: > > http://ipython.scipy.org/doc/rel-0.9.1/html/interactive/reference.html > (Search for bookmark) > > Is there similar functionality in fish that I have missed? Or is there a > system or recommendation that other fish users use that they would like to > share? > There is $CDPATH - an array of directories under which `cd` looks up its argument. It defaults to: > set -U | grep CD CDPATH '.' '/home/beni' so that if you do ``cd foo`` and ./foo doesn't exist but ~/foo does, it will go to ~/foo. So it's not bookmarking per-se, but if you want to bookmark /foo/bar/baz, you can ``set CDPATH $CDPATH /foo/bar`` and ``cd baz`` would work afterwards (from any directory that doesn't have a direct ./baz subdir). It's a universal variable, so it's saved and shared among all fish sessions. For extra credit, note TAB-completion after ``cd `` is aware of the CDPATH! This feature is modelled on bash's $CDPATH (which IIRC was modeled on tcsh's $cdpath). I must say I'm not entirely happy with it. Bookmarking specific dirs would be easier to use IMHO. It does work pretty conveniently if you have the habit of bookmarking dirs by symlinking them under ~/ or ~/Links/ or something like that (which is a good habit because such links are accesibble by any program, not just your shell). Then by adding ~/ or ~/Links/ to $CDPATH you can do ``cd foo`` and get to ~/Links/foo. [Also if you use ~/, you don't really need any help, ``cd ~/foo`` is short enough IMHO.] Then of course, there is also the alias way of bookmarking: function cdalias switch (count $argv) case 0 set dir $PWD set name cd-(basename $dir) case 1 set dir $argv[1] set name cd-(basename $dir) case 2 set name $argv[1] set dir $argv[2] case '*' echo 'Usage: cdalias [[name] dir]' exit 2 end function $name cd $dir end funcsave $name end This allows you to bookmark individual directories, avoid ambiguity (``cd baz`` vs. ``cd-baz``) and supports completion (``cd-<TAB>``). Erasing them is a bit tedious (requires erasing ~/.config/fish/functions/cd-baz.fish, and that doesn't affect open sessions where you have executed the function already; but changing the alias does affect existing sessions immediately). Last, there is the variable approach to bookmarking: > set -U $baz /foo/bar/baz > cd $baz But that's annoying because completion doesn't work (unless you adopt a prefix like ``cd $cd-baz`` which is redudant). P.S. while we are talking, you are aware of fish's magic Alt+Left / Alt+Right shortcuts that go forward and backward in directoy history (when the command line is empty)? -- Beni <[email protected]> -- Beni <[email protected]> ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
