agkozak/zsh-z

Show ~ as prefix for HOME instead of absolute paths

MicahElliott opened this issue · 13 comments

Just a little annoying to see:

0.36       /Users/micahelliott/work
0.71       /Users/micahelliott/exp
1.07       /Users/micahelliott/exp/clj/rmq
5.05       /Users/micahelliott/exp/clj
11.17      /Users/micahelliott/exp/clj/rmq/lang1
16         /usr/local/bin
45.14      /Users/micahelliott/work/foo
58.73      /Users/micahelliott/.zplug
167.84     /Users/micahelliott/tmp

when it could be easier to read as:

0.36       ~/work
0.71       ~/exp
1.07       ~/exp/clj/rmq
5.05       ~/exp/clj
11.17      ~/exp/clj/rmq/lang1
16         /usr/local/bin
45.14      ~/work/foo
58.73      ~/.zplug
167.84     ~/tmp

I agree, and I've thought of making that change in the past. I hesitate, however, because this is still a drop-in replacement for rupa/z, and a few other utilities use the output of z -l to provide completions. I'll continue to look at this issue.

Was looking for this! I searched for relative and couldn't find it (now that the word is here, hopefully it will come up for others). Would love this! I switch between a work and personal computer, and this will prevent needing to adjust for forced/different account/home names.

Edit: Context—I made an assumption that isn't obvious—I commit my home folder (parts of it, including my .zsh* settings) to git.

@MicahElliott and @voltechs -

I'd like you to try out the feature you requested. It's on the tilde branch, so use that and set

ZSHZ_TILDE=1

That should alter the display of z -l, z -e, and the new ZSHZ_ECHO output.

Let's test it a bit.

@agkozak awesome! I'll give it a shot next time I'm at my computer.

@agkozak Seems to be working with ZSHZ_TILDE=1 set. Thx!

@agkozak after some jostling, I got z -l and z -e to output with ~, however, my .z file still shows full paths. Did I miss a step?

@voltechs I'll probably always avoid changing the database file format if I can. It's something we share with z.sh and other tools.

Are you actually commiting ~/.z or its equivalent to Git and moving it from machine to machine?

@agkozak oh I see. Yes, I'm committing this file to git, as it's nice to have those shortcuts handy across devices. I suppose, however, that it's a small sacrifice to not have this. Ultimately, any moderate amount of use on the machine would end up generating the paths, but it would be nice to have the shortcuts present prior to specifically visiting each location on each machine. I usually keep a similar structure for things (bin, workspace etc), the only thing that might change is the username. Even if the username stays the same, the root path between a FreeBSD and a Darwin system (for example) is different so ultimately the absolute paths do not work, but the home-relative paths would.

I know what you mean. In my case, I use two systems. ZSH supplies us with the command hash -d, so my .zshrc has the lines

[[ -d ${HOME}/.zinit/plugins/agkozak---zsh-z ]] &&
  hash -d z="${HOME}/.zinit/plugins/agkozak---zsh-z"

That way, with setopt AUTOCD on, I can just type cd z and I get to my ZSH-z directory. I use ZSH-z for its original purpose -- guessing where I want to go based on my behavior and the individual layout of each computer's directory tree. By default, ZSH-z forgets about any paths that aren't present on your machine, so you can lose a lot when you move the database (though ZSHZ_KEEP_DIRS can be used to prevent that from happening).

@agkozak that's a clever trick. My particular OCD has all my zsh related things in ~/.zsh/ including my .zshrc, .zshenv and my .z "database". This is committed in my "home git" repo, so that it transfers between systems. I probably don't need to be so OCD about it, and just not commit this file to git. Seems as this issue/proposed improvement is really just cosmetic with respect to dumping one's z database. Doesn't work for my situation, but certainly still a meaningful improvement never-the-less!

Is this gonna get merged in?

Is this gonna get merged in?

Yes -- thanks for asking! Give me another day or two.

OK - the ZSHZ_TILDE option is now part of the master branch. Thanks, everyone.