Hacker News new | ask | show | jobs
by alanh 5596 days ago
I like this workflow better:

1. Go to the directory in question

2. Type "save nm" where "nm" is any short name for the directory, like "blog" or "blg"

3. From now on, type "cd nm" whenever you want to go there.

No session restart required, even.

I copied the code that enables this workflow from http://dotfiles.org/~jacqui/.bashrc (or was it https://gist.github.com/117528)

The idea is discussed here: http://hints.macworld.com/article.php?story=2002071600512379...

3 comments

Or in zsh:

    setopt cdablevars
    nm=/path/to/whatever
    cd nm
you can put this in ~/.zshrc for persistent zsh bookmarks

  touch ~/.zshmarks && source ~/.zshmarks
  function b() {
    echo "hash -d $1=\"`pwd`\"" >> ~/.zshmarks && source ~/.zshmarks
  }
or you could just put some paths on your cdpath and enable autocd.
and then you just cd by typing ~bookmark
in Bash, change the first line to:

    shopt -s cdable_vars
in Bash you don't even need to do that, just do:

    foo=/etc/
    cd $foo
Dollars to donuts the author is a Vimmer. I am and the workflow makes complete sense to me :-)
Why not just:

    echo "export nm=`pwd`/blog"' >> ~/.profile
    . ~/.profile
    cd $nm
There's no need for magic when you know how to shell.
Why not just

    shopt -s cdable_vars
    nm=`pwd`/blog
    cd nm
No need for hacks when you know how to shell.
Annoying special cases:

    $ cd /
    $ nm=/foo
    $ ls | grep nm
    $ cd nm
    $ pwd
    /foo
    $ cd ~
    $ ls | grep nm
    nm
    $ cd nm
    $ pwd
    ~/nm
    $ echo FFFFFUUUUUUUUU
Inflexible:

    $ cd nm/jan/img
    cd: No such director nm/jan/img
    $ echo SHIT
    SHIT
    $ cd $nm/jan/img
Worse, It's nonstandard and only saves you one chracter.