Live data from Hacker News

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

huyng.com

51–60 of 124 posts

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

#51

Try autojump, I love it - https://github.com/joelthelion/autojump/wiki

Just to help sell it some more: autojump basically watches where you cd and builds a model (of some sort) that guesses where you want to go based on a few characters.

For instance, I have a project called "structured-prediction" deep in some folder hierarchy, and I can just type "j stru" or "j pred" or even "j uct" and it goes to the directory.

The best part is that it figures this out automatically. You don't have to remember to bookmark anything.

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

#53
post #41

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…

Open one per directory you want to operate in, for instance. This is a common source of headache when using the terminal as an IDE. Not only is it easy to get lost in a sea of terminal-tabs, but it's also quite cumbersome to restore the state of 5+ tabs after a shutdown or disconnect. Even more so when GNU screen enters the mix. What I'd really like to have is a terminal that can attach to a remote GNU screen and dis…

So browsing graphical tabs is quicker for you then using "Ctrl+RightArrow" or "Ctrl+n" or some variation of one of those? Traversing my screen or tmux sessions is usually much faster than using a mouse.

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

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

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

#55

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.

Appending ";cd -" on the end will have the same effect.

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

#56
post #41

Earlier quoted context omitted.

Open one per directory you want to operate in, for instance. This is a common source of headache when using the terminal as an IDE. Not only is it easy to get lost in a sea of terminal-tabs, but it's also quite cumbersome to restore the state of 5+ tabs after a shutdown or disconnect. Even more so when GNU screen enters the mix. What I'd really like to have is a terminal that can attach to a remote GNU screen and dis…

So browsing graphical tabs is quicker for you then using "Ctrl+RightArrow" or "Ctrl+n" or some variation of one of those? Traversing my screen or tmux sessions is usually much faster than using a mouse.

Traversing is not the issue here, it's more about having an ad-hoc way to watch things side-by-side by dragging a tab to a window and vice versa, and about having a proper scrollback.

Yes, screen, tmux and vim have split window modes, but those are cumbersome to operate (and I'm saying that as a year-long ion3 user) and the scrollback issue has not been addressed by either up to this day.

Or, to put it more generally: Terminals are sadly stuck firmly in the 1970s. There has been near zero innovation beyond emulating them in tabbed windows and setting xterm titles. Heck, we're moving backwards. OSX ships with a terminal that doesn't even support 256 colors. ZModem is unheard of except in fairly exotic/old emulators such as Zoc. Support for "advanced" terminal features (double-size fonts, graphics mode) is rare.

I spend >8hrs/day inside a terminal. I would happily pay a 3 digit license fee for a modern terminal emulator that adds the features I mentioned and innovates beyond. There's infinite room for innovation by leveraging special ESC-sequences (server tells terminal what to do), drag & drop, integrating with tools like screen, ssh or even building new CLI tools that interface with the terminal in a smart way...

I want vim to tell my terminal to display NerdTree in a native side-car widget like TextMate. I want an "open" CLI-command that downloads the target-file from the remote server and displays it locally without me having to futz with scp. I want to drag & drop files onto the server that I'm currently ssh'd into. I want the term to maintain my entire session (including all tabs and remote connections) across reboots. And, yes, I'd like to have my remote screen windows line up neatly as native tabs.

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

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

There are also a lot of scripts that assume CDPATH isn't being used; for instance any hadoop-based project will break if it's set.

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

#58

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.

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

#59
post #51

Try autojump, I love it - https://github.com/joelthelion/autojump/wiki

Just to help sell it some more: autojump basically watches where you cd and builds a model (of some sort) that guesses where you want to go based on a few characters. For instance, I have a project called "structured-prediction" deep in some folder hierarchy, and I can just type "j stru" or "j pred" or even "j uct" and it goes to the directory. The best part is that it figures this out automatically. You don't have t…

I use this tool all day, everyday. It should be built into bash.

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

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

Post reply on HN