Live data from Hacker News

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

huyng.com

101–110 of 124 posts

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

#103
post #2

I've also wondered to myself why there isn't a terminal program with a directory tree by the side so you could just click on the directory that you want to be in, instead of ls -cd-tab-blah-^H-tab-^M. It would also a have a list of favorite and most-recently-used directories. A weekend project, perhaps...

I use Dolphin sometimes for this reason, so that I can navigate the directory tree/places via mouse but use the console pane as normal.

Krusader also has a built in console pane.

Not strictly a terminal as the console is running over KDE over X, ..., but works for me.

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

#104
post #45
post #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.mac…

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
  }

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

#105
post #104
post #45

Earlier quoted context omitted.

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 }

and then you just cd by typing ~bookmark

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

#106
post #90
post #71

Earlier quoted context omitted.

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.

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

#107

Why is a home-rolled cd script interesting when there are many more mature, feature-rich cd-tools out there? * http://www.skamphausen.de/cgi-bin/ska/CDargs * http://micans.org/apparix/ * http://github.com/joelthelion/autojump * http://github.com/rupa/z * http://github.com/flavio/jump Also, the title is misleading. I thought it was actually a commandline tool that removed the need to cd most of the time, like lightnin…

Ditto, this one feels like reinventing the wheel when we have the tools you named.

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

#109
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've created an AUR package for this script, found here: http://aur.archlinux.org/packages.php?ID=46675

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

#110
post #4

There's also the pushd and popd commands which are part of bash already. And there's a wikipedia entry for this even: http://en.wikipedia.org/wiki/Pushd_and_popd

You can also use the "dirs" command (I think part of bash as well) that tells you the state of the stack. If you set the -v option, you can get the depth of different directories, and you can just do pushd +N to jump to the specific directory.

funny- I don't see man pages (nor info pages) for pushd, popd, or dirs. What am I missing about the documentation?
Post reply on HN