Live data from Hacker News

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

huyng.com

91–100 of 124 posts

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

#91
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 lightning: http://tagaholic.me/2010/04/08/lightning-speed-for-your-shel...

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

#93

Yet another time saver: if you need to execute only a single command in another directory, use: (cd /path; command) This will cd to /path, run command, but return you to your original working directory. This works because the parens create a sub-process, and the cd command only affects that sub-process.

I prefer (cd /path && command), since that way if the cd fails for some reason (like you've typo'd the path), it won't still attempt to run the command.

Of course! I actually do always use double-ampersand for chaining commands in bash, not sure what made me use a semicolon in that example. Thanks for the correction, a small but important distinction.

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

#94

I first was excited by title "Don't waste your time by cd-ing in the terminal", but then it just turned out to be a blog post about making cd'ing quicker. If you want to boost your productivity, my advice is to stop cd'ing altogether. I see a lot of people -- particularly vi users -- cd'ing back and forth through a large directory tree. I usually tell them to get a terminal emulator that lets you easily manage many t…

a terminal emulator which has a session sasving feature built in to restore terminal tabs with their working directories is: termit find it on github. lua scripting api included :)

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

#95
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…

[deleted]

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

#96
post #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.

Ctrl-r is what I use too. Usually requires fewer keystrokes than other methods discussed here. And it works for all commands in shell history.

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

#97
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.

Gorgeous!

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

#98

1. How about we just learning to type fast(-er) and use file name completion 2. Use real shell like ksh, where history search actually works 3. cd $OLDPWD is occasionally helpful. Occasionally. Kids...

Exactly. OP is doing gymnastics to solve a non-problem.

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

#99
post #73

Why not just use symlinks for your bookmarks? pushd and popd are also useful.

I got bitten with symlinks for bookmarks. They don't change the PWD to the correct one. For example:

  cd /home/nick
  ln -s /var/www www
  cd www
  echo $PWD --->  /home/nick/www
which will break scripts.

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

#100
post #78
post #74

Earlier quoted context omitted.

You can get this by editing files over sshfs. Been there, it's a kludge and tends to not cope well with network disconnects. Also when sshfs flakes out then it has a habit of leaving you with 0-byte files. Also note this doesn't fully address the problem. I literally want to drag/drop into the current directory of whatever server I'm ssh'd into (possibly with multiple ssh-hops in between). This has been possible in t…

I've also been frustrated by these issues. I want to be able to edit a file with local typing speed (i.e., gvim on Windows), but then be able to hit a key and be in a terminal window on that server in that folder to perhaps do a manual grep or rebuild an index or whatever. I feel like we were closer in the 90s with innovative products like Slirp and Term and, yes, Zmodem (and Kermit). I started trying to build out so…

Sounds like you want Emacs' tramp. On your local emacs, open a file in the form "/user@remote-ssh-host:file" and it will grab the remote file and edit it locally. Crazily all the emacs version control commands and stuff like M-x compile and M-x grep all work in the remote context. Very cool stuff.

Obviously this requires that you use Emacs instead of Vim though. Don't be afraid though, the grass is pretty green over here :-).

Post reply on HN