[lug] CDPATH?
Tyler Cipriani
tyler at tylercipriani.com
Thu Apr 14 10:48:20 MDT 2016
Here's a useful thing that I've setup recently, it's a variation on
Jeroen Janssens's method[0] of quick filesystem naviagation:
In your ~/.bashrc (or other shell initialization file)
1. Create a mark function:
mark() { mkdir -p "$HOME/.marks"; ln -s "$(pwd)" "$HOME/.marks/$1" }
2. Alias cd to cd -P:
cd='cd -P'
3. Make sure "$HOME/.marks" is in your CDPATH variable:
export CDPATH="$HOME/.marks"
To use this system, simply use the mark function when you're in a
directory to create an alias for that directory that you can cd to
from anywhere in the filesystem:
(ノ^ヮ^)ノ*:・゚✧ pwd
/home/tyler
(ノ^ヮ^)ノ*:・゚✧ mkdir -p tmp/some/really/deep/file/structure/omg/so/long
(ノ^ヮ^)ノ*:・゚✧ cd !$
cd tmp/some/really/deep/file/structure/omg/so/long
(ノ^ヮ^)ノ*:・゚✧ mark deep
(ノ^ヮ^)ノ*:・゚✧ cd
(ノ^ヮ^)ノ*:・゚✧ pwd
/home/tyler
(ノ^ヮ^)ノ*:・゚✧ cd deep
/home/tyler/.marks/deep
(ノ^ヮ^)ノ*:・゚✧ pwd
/home/tyler/tmp/some/really/deep/file/structure/omg/so/long
Tada!
Tyler
0. http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
On 16-04-14 06:26:34, Jeffrey S. Haemer wrote:
> Jed,
>
> Another helpful tweak for cd is "shopt -s globstar"
>
> shopt -s globstar
> mkdir -p a/b/c/d/e
> cd **/e
> pwd
>
>
> It's no DWIM, but sometimes it's a good shortcut. I'm lazy and a bad
> typist, so my .bashrc includes this:
>
> shopt -s cdspell dirspell globstar
>
> Also this:
>
> alias mroe=more # for Evi
>
> Perhaps, however, tonight's emacs talk will include ways to use DWIM
> commands to turn emacs into the shell-of-your-dreams. :-)
>
> On Wed, Apr 13, 2016 at 6:38 PM, Jed S. Baer <blug at jbaer.cotse.net> wrote:
>
> > On Wed, 13 Apr 2016 17:59:47 -0600
> > Zan Lynx wrote:
> >
> > > Notice that "warez" is not in your CDPATH. To make "cd warez" work you'd
> > > need "CDPATH=/home/jbaer/incoming"
> >
> > Aha. Somehow, I had it in my head it'd be recursive. Funny, how the brain
> > works sometimes. Thanks.
> > _______________________________________________
> > Web Page: http://lug.boulder.co.us
> > Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> > Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
> >
>
>
>
> --
> Jeffrey Haemer <jeffrey.haemer at gmail.com>
> 720-837-8908 [cell], http://seejeffrun.blogspot.com [blog],
> http://www.youtube.com/user/goyishekop [vlog]
> *פרייהייט? דאס איז יאַנג דינען וואָרט.*
> _______________________________________________
> Web Page: http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
More information about the LUG
mailing list