News for hackers. Stuff that matters.
Re:Don't waste your time by cd-ing in the terminal by alanh on Friday February 18, 2011 @07:44PM (#2237928)
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...

Re:Don't waste your time by cd-ing in the terminal by sjs on Friday February 18, 2011 @08:11PM (#2237990)
Or in zsh:

    setopt cdablevars
    nm=/path/to/whatever
    cd nm
Re:Don't waste your time by cd-ing in the terminal by irfn on Saturday February 19, 2011 @05:41AM (#2238846)
you can put this in ~/.zshrc for persistent zsh bookmarks

  touch ~/.zshmarks && source ~/.zshmarks
  function b() {
    echo "hash -d $1=\"`pwd`\"" >> ~/.zshmarks && source ~/.zshmarks
  }
Re:Don't waste your time by cd-ing in the terminal by spicycode on Saturday February 19, 2011 @11:01AM (#2239221)
or you could just put some paths on your cdpath and enable autocd.
Re:Don't waste your time by cd-ing in the terminal by irfn on Saturday February 19, 2011 @05:43AM (#2238848)
and then you just cd by typing ~bookmark
Re:Don't waste your time by cd-ing in the terminal by unfletch on Saturday February 19, 2011 @12:02AM (#2238439)
in Bash, change the first line to:

    shopt -s cdable_vars
Re:Don't waste your time by cd-ing in the terminal by _b8r0 on Saturday February 19, 2011 @05:18AM (#2238828)
in Bash you don't even need to do that, just do:

    foo=/etc/
    cd $foo
Re:Don't waste your time by cd-ing in the terminal by hyperbovine on Friday February 18, 2011 @10:55PM (#2238324)
Dollars to donuts the author is a Vimmer. I am and the workflow makes complete sense to me :-)
Re:Don't waste your time by cd-ing in the terminal by anon_d on Friday February 18, 2011 @10:11PM (#2238236)
Why not just:

    echo "export nm=`pwd`/blog"' >> ~/.profile
    . ~/.profile
    cd $nm
There's no need for magic when you know how to shell.
Re:Don't waste your time by cd-ing in the terminal by fabjan on Saturday February 19, 2011 @01:43AM (#2238622)
Why not just

    shopt -s cdable_vars
    nm=`pwd`/blog
    cd nm
No need for hacks when you know how to shell.
Re:Don't waste your time by cd-ing in the terminal by anon_d on Saturday February 19, 2011 @06:09AM (#2238866)
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.