News for hackers. Stuff that matters.
Re:Z - Jump to directories that you actually use. by ackyshake on Saturday September 01, 2012 @12:59PM (#4464299)
I use fasd, which is just like z, v, autojump, only much more powerful: https://github.com/clvv/fasd
Re:Z - Jump to directories that you actually use. by rjzzleep on Saturday September 01, 2012 @05:58PM (#4465279)
you get + 100 karma for posting that. I can't believe I didn't come up with something similar in all these years
Re:Z - Jump to directories that you actually use. by phlyingpenguin on Saturday September 01, 2012 @03:07PM (#4464742)
It's even based on Z, cool. You've reminded me to update my copy as the version I'm using is f.sh!
Re:Z - Jump to directories that you actually use. by possibilistic on Saturday September 01, 2012 @07:02PM (#4465436)
This looks like a serious productivity boost. Where has it been hiding all my life?

Thanks a million! :D

Re:Z - Jump to directories that you actually use. by wamatt on Sunday September 02, 2012 @06:07AM (#4466678)
Seriously handy, thanks! I was about to dive into Z, but this looks even better.
Re:Z - Jump to directories that you actually use. by 4ad on Sunday September 02, 2012 @06:10AM (#4466687)
No tricks, just regular cd:

  % pwd
  /home/aram
  % cd mstate
  /home/aram/src/launchpad.net/juju-core/mstate
  % cd go/src
  /home/aram/go/src
  % cd plan9
  /home/aram/plan9
  %
It uses the $CDPATH environment variable ($cdpath in rc(1)). $CDPATH is a list of places in which to search for the wanted directory. I put all the things I regularly use there, and my cds are almost always short, usually just a single name.

I don't maintain $CDPATH myself, my profile runs a one liner that descends into certain directories and constructs $CDPATH for me within the constrains of some rules (for example excludes leafs, excludes {bin,doc,pkg,test}, etc).

Finding about $CDPATH was a huge productivity boost to me, not only in time saved typing, but in allowing me to change the way I work. I now rarely care where things in the filesystem are (e.g. various source code for various software, where the build products are, etc). I used to do a lot of moving and symlinking around, to arrange stuff so I remember where I've put it and to keep paths short, but now I don't care. It could be wherever, it's just one name away. The namespace had become a big hash.

Re:Z - Jump to directories that you actually use. by wting on Sunday September 02, 2012 @10:20AM (#4467061)
This is a pretty good solution, however there are a few things other programs add on:

- $CDPATH requires manual management. You're using a line in profile, but I imagine that's limited to specific directories and creates overhead when creating new shells. - What happens with namespace collision? First entry in $CDPATH wins? - Fuzzy searching for mistyped directory names. I don't find this feature that useful personally, but was requested quite a bit by others.

William (autojump maintainer)

Re:Z - Jump to directories that you actually use. by 6ren on Sunday September 02, 2012 @07:39AM (#4466797)
Just tried this to see if tab-completion works. It does (only for cd of course). BTW: what is "rc(1)"?
Re:Z - Jump to directories that you actually use. by 4ad on Sunday September 02, 2012 @08:12AM (#4466837)
Rc(1) is the Unix v10/Plan 9 shell[1] written by Tom Duff[2], of Duff's device[3] fame. Rc(1) is of course available in Unix as well, I use the port from plan9port[4].

[1] http://doc.cat-v.org/plan_9/4th_edition/papers/rc

[2] http://en.wikipedia.org/wiki/Tom_Duff

[3] http://en.wikipedia.org/wiki/Duff%27s_device

[4] http://swtch.com/plan9port/

Re:Z - Jump to directories that you actually use. by awayand on Sunday September 02, 2012 @08:56AM (#4466896)
|my profile runs a one liner... what's that one liner look like?
Re:Z - Jump to directories that you actually use. by 4ad on Sunday September 02, 2012 @09:08AM (#4466917)
I lied, seems to be 5 lines total :-)

  export CDPATH=.:~
  cdpaths="$([ -d ~/src ] && find ~/src -mindepth 1 -type d | egrep -v '/(\.)|_[a-zA-Z0-9]' | egrep -v '(bin)|(cmd)|(doc)|(lib)|(pkg)|(test)' | xargs -n1 dirname | uniq)"
  for i in $cdpaths; do
  	CDPATH=$CDPATH:$i
  done
Re:Z - Jump to directories that you actually use. by mathieuh on Saturday September 01, 2012 @01:26PM (#4464389)
Fish-compatible version: https://github.com/sjl/z-fish
Re:Z - Jump to directories that you actually use. by StavrosK on Saturday September 01, 2012 @05:02PM (#4465125)
Thanks for that, added! It looks pretty promising.
Re:Z - Jump to directories that you actually use. by bhudman on Saturday September 01, 2012 @12:58PM (#4464295)
I've been using a tool called autojump that does a similar thing and I love it.. https://github.com/joelthelion/autojump

Tools like Z and autojump are fantastic timesavers.

Re:Z - Jump to directories that you actually use. by grimgrin on Saturday September 01, 2012 @01:03PM (#4464311)
If you like his Z, check out his V (if you use Vim).

https://github.com/rupa/v

Re:Z - Jump to directories that you actually use. by shawndumas on Saturday September 01, 2012 @02:21PM (#4464583)
CDPATH, as desribed in man bash

'The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command. A sample value is ".:~:/usr".'

Re:Z - Jump to directories that you actually use. by olalonde on Saturday September 01, 2012 @11:44PM (#4466054)
In case anyone else is wondering what "frecency" is:

Frecency is a portmantaeu of ’recent’ and ’frequency’. It is a weighted rank that depends on how often and how recently something occured. As far as I know, Mozilla came up with the term.

Re:Z - Jump to directories that you actually use. by ericb on Saturday September 01, 2012 @12:50PM (#4464277)
I have been using this--very handy. Is there a version that doesn't cd? It'd be nice for ls, etc.
Re:Z - Jump to directories that you actually use. by tehwalrus on Saturday September 01, 2012 @02:21PM (#4464581)
just use an alias wrapper like:

  alias zls='z \!*;ls;cd -'
(with additional zll etc for ls -l or -a)
Re:Z - Jump to directories that you actually use. by wahnfrieden on Saturday September 01, 2012 @12:21PM (#4464158)
Is this good for zsh? Is there a preferred alternative?
Re:Z - Jump to directories that you actually use. by jkjeldgaard on Saturday September 01, 2012 @01:35PM (#4464424)
It works just fine with zsh. If you're on a mac you can easily install z (and keep it up to date) with `brew install z`
Re:Z - Jump to directories that you actually use. by crcastle on Saturday September 01, 2012 @03:52PM (#4464891)
FYI - The caveat for how to set up z for zsh were wrong in brew. I just submitted a pull request to fix this.

https://github.com/mxcl/homebrew/pull/14621

Re:Z - Jump to directories that you actually use. by metamorfos on Saturday September 01, 2012 @04:15PM (#4464976)
Great, updating brew asap!
Re:Z - Jump to directories that you actually use. by chanux on Saturday September 01, 2012 @01:50PM (#4464479)
Shameless plug: Bash function to jump back in path

https://gist.github.com/1119556

Re:Z - Jump to directories that you actually use. by cpeterso on Saturday September 01, 2012 @02:08PM (#4464533)
In bash, you can just cd - to pop back to the previous working directory, like popd without the pushd.

I also set .bash_profile aliases to quickly cd up the directory tree with just dots. It's silly, but surprising helpful.

  alias ..='cd ..'
  alias ...='cd ../..'
  alias ....='cd ../../..'
Re:Z - Jump to directories that you actually use. by chanux on Saturday September 01, 2012 @02:54PM (#4464697)
I did some Googling and was not satisfied with any of the solutions (pushd/popd, aliases, CDPATH etc.). That's why I wrote this. Works fine for me :)

PS: The whole story on my blog https://chanux.wordpress.com/2012/08/09/no-more-cd-dot-dot-s...

Re:Z - Jump to directories that you actually use. by zaptheimpaler on Saturday September 01, 2012 @02:33PM (#4464639)
I like that idea, I could definitely see it being helpful. I've type cd.. too many times when I meant to say cd ..
Re:Z - Jump to directories that you actually use. by cpeterso on Sunday September 02, 2012 @10:23PM (#4468883)
me too. That's why I also:

  alias cd..='cd ..'
:)
Re:Z - Jump to directories that you actually use. by klibertp on Saturday September 01, 2012 @07:50PM (#4465551)
At least '..' is defined by default in zsh.
Re:Z - Jump to directories that you actually use. by manojlds on Sunday September 02, 2012 @03:50AM (#4466503)
Posz for Powershell - https://github.com/manojlds/posz
Re:Z - Jump to directories that you actually use. by StavrosK on Saturday September 01, 2012 @05:03PM (#4465127)
Does anyone know what the initial --add is for? I'm using z-fish and I'm wondering if I can elide it.
Re:Z - Jump to directories that you actually use. by pooriaazimi on Saturday September 01, 2012 @12:08PM (#4464106)
It's a wonderful little tool. I love it. Give it a try, you won't regret!