Live data from Hacker News

Don't waste your time by cd-ing in the terminal

huyng.com

31–40 of 124 posts

Re: Don't waste your time by cd-ing in the terminal

#33
Hey Guys,

This is my blog.

FWIW, I've actually switched away from using the script mentioned in the link posted by OP and have moved towards using an improved version below.

http://www.huyng.com/bashmarks-directory-bookmarks-for-the-s...

This new version has 3 commands:

    - "s" for save current directory as a bookmark
    - "g" for jump to bookmark's directory
    - "l" for list all bookmarks.

Re: Don't waste your time by cd-ing in the terminal

#34
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

#35
post #5

Don't waste your time bookmarking directories, jump right to them ;) https://github.com/rupa/z `z` tracks your most used directories. After a short learning phase, it will take you to the directory, based on its usage frequency and a hint you give it on the command line. Say I am often cd'ing into /var/www - then after a while I can just type `z ww`.

I remember seeing this, but forgot entirely to use it. Have been spending a while looking for it again, or something equivalent. Thanks.

Re: Don't waste your time by cd-ing in the terminal

#36

Another built-in worth knowing about is CDPATH.[1] I find that setting a sane CDPATH and bash-completion makes cd-ing anywhere I go regularly pretty trivial - just a few letters and a few TABs and I'm good to go. [1] http://caliban.org/bash/#bashtips

I'd be extremely careful with CDPATH, never use this on an important host.

Having "cd foo" potentially take you to an entirely different location can be dangerous, to say the least.

Re: Don't waste your time by cd-ing in the terminal

#38
post #35
post #5

Don't waste your time bookmarking directories, jump right to them ;) https://github.com/rupa/z `z` tracks your most used directories. After a short learning phase, it will take you to the directory, based on its usage frequency and a hint you give it on the command line. Say I am often cd'ing into /var/www - then after a while I can just type `z ww`.

I remember seeing this, but forgot entirely to use it. Have been spending a while looking for it again, or something equivalent. Thanks.

I forgot the url, too. But then I remembered the tagline "z is the new j" - which is enough for google to bring up the repo - even without quotes.

Re: Don't waste your time by cd-ing in the terminal

#39
post #36

Another built-in worth knowing about is CDPATH.[1] I find that setting a sane CDPATH and bash-completion makes cd-ing anywhere I go regularly pretty trivial - just a few letters and a few TABs and I'm good to go. [1] http://caliban.org/bash/#bashtips

I'd be extremely careful with CDPATH, never use this on an important host. Having "cd foo" potentially take you to an entirely different location can be dangerous, to say the least.

I'm not sure I follow. There's nothing dangerous about cd-ing to a directory, though of course it could be dangerous to start work in 'foo', thinking it was 'bar'. Most people use a prompt, or the title bar of their shell to protect against that. But either way, I'm not sure how CDPATH makes that danger greater than any other trick that allows you to jump quickly to a directory using a bookmark, popd or the like.
Post reply on HN