Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The "navigation aliases" IMHO are better handled as ENV vars.

The example

    alias dev="cd ~/dev/"
    alias personal="cd ~/dev/thorstenhans"
    alias business="cd ~/dev/thinktecture"
Becomes

    export dev=~/dev
    export personal=~/dev/thorstenhans
    export business=~/dev/thinktecture
And now thanks to the way ZSH handles directories, you can still simply change directory with

    $ ~dev
    $ ~personal
    $ ~business
and it'll work as before but it also allows you to treat it as a fully qualified directory in other commands which I find exceedingly useful

    $ tree ~dev
    $ cat ~personal/index.html
    $ rm -rf ~business/secret-documents


You can directly create named directories with `hash -d`. Eg.

    hash -d dev=~/dev
    hash -d personal=~/dev/thorstenhans
    ...
Nothing else is needed.


I'd argue environmental variables have the strong advantage in that you can use them in cases that won't otherwise expand, namely programs that take a path parameter immediately following an equals, e.g.

    $ docker run --workdir=$dev foo
in these cases `--workdir=~dev` is not expanded and fails as docker does not understand your alias.


True and I often have both. I like my exported environment variables to be all caps and my directory aliases to be lowercase. This keeps their uses separate.


I'm too lazy to shift-tilde




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: