Live data from Hacker News

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

huyng.com

81–90 of 124 posts

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

#81
post #47
post #43

Earlier quoted context omitted.

nice stuff. You got your dotfiles on a github?

I know you didn't ask me, but you might find something you like here: https://github.com/samsonjs/config (dot files) and https://github.com/samsonjs/bin

appreciated, thanks!

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

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

in Bash, change the first line to:

    shopt -s cdable_vars

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

#83
post #22

Earlier quoted context omitted.

What's the bash equivalent to zsh's "setopt autopushd"?

I don't know what that is, but does it do more than alias cd='pushd'?

That's essentially what it does, but if you use the "autocd" option as well, you don't need to type "cd" - you can just use the name of a directory as a command. So, "autopushd" would ensure that these operations use the directory stack also.

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

#84
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 want to be able to preview the path or directory name that z will navigate to. Something like the way the webkit developer console autocompletes an object, method, or property in light gray color. Or it could be displayed in the terminal title bar. Is that possible?

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

#85
Maybe it's just because I run a lot of the same commands and don't do a lot of development from the terminal, but I avoid cding at all usually and just type the full path. It svaes time over multiple sessions thanks to ctrl+r, and the commands in my history work no matter what dir I'm in.

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

#87
post #60
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...

Unrelated but a nice alias "tree". alias tree="find . -name .svn -prune -o -name .DS_Store -prune -o -name .git -prune -o -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'" It shows your directory listing in the form of a tree. Easier to visualize.

Nice little hack!

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

#90
post #71
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…

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.
Post reply on HN