News for hackers. Stuff that matters.
Re:UNIX Tips and Tricks To Save You Time In Terminal by pstadler on Wednesday October 09, 2013 @11:02AM (#6521632)
Don't use too many aliases, a dozen generic ones should do it, learn to use reverse history search (usually mapped to Ctrl-r) instead.

Once you get used to it, your brain just triggers this combination whenever the command is more complex than let's say `ls -al`. This means you have to change some habits like to `tail` your logs with absolute paths, so you don't need to `cd` into the folder first, etc.

Re:UNIX Tips and Tricks To Save You Time In Terminal by WestCoastJustin on Wednesday October 09, 2013 @11:27AM (#6521818)
If anyone is interested, there were several great posts on Hacker News a while, these are packed with useful UNIX commands [0, 1, 2, 3].

[0] https://news.ycombinator.com/item?id=6360320

[1] https://news.ycombinator.com/item?id=6046682

[2] https://news.ycombinator.com/item?id=5022457

[3] https://news.ycombinator.com/item?id=4985393

Re:UNIX Tips and Tricks To Save You Time In Terminal by waxjar on Wednesday October 09, 2013 @09:16AM (#6521018)
Half these "unix tricks" are bash tricks. :/
Re:UNIX Tips and Tricks To Save You Time In Terminal by agumonkey on Wednesday October 09, 2013 @11:33AM (#6521870)
This is what Gary Bernhardt would call 'atom' level unix programming. I encourage people to watch this talk : http://www.confreaks.com/videos/615-cascadiaruby2011-the-uni...

First it's quite funny, second it shows very pragmatic yet abstract usage of unix way of life, like quickly gathering data about your code base by combining other these atoms into new abstractions (as in SICP).

As he says, it's often half-assed, but it's the right half of the ass.

Re:UNIX Tips and Tricks To Save You Time In Terminal by rdtsc on Wednesday October 09, 2013 @10:19AM (#6521359)
Obligatory:

http://www.commandlinefu.com/

I found some nice tricks there that I ended up using.

On the other hand, I found that customizing my shell, emacs, and other such things too much a bit frustrating when dealing with multiple machines. So often I have learned to live with the defaults. In other words I don't want to get used to typing "gst" for "git status" I just type "git status" because next machine I log into might not have the gst alias.

Re:UNIX Tips and Tricks To Save You Time In Terminal by milliams on Wednesday October 09, 2013 @10:43AM (#6521508)
http://explainshell.com/ is pretty funky too.
Re:UNIX Tips and Tricks To Save You Time In Terminal by pstadler on Wednesday October 09, 2013 @11:10AM (#6521696)
This is really cool. Thanks for posting that!
Re:UNIX Tips and Tricks To Save You Time In Terminal by oostevo on Wednesday October 09, 2013 @01:03PM (#6522428)
I've also found the book "From Bash to Z Shell - Conquering the Command Line" very, very useful.[1] It's written as a beginner text, but even after ~15 years of *nix usage, I've learned a huge amount of new information, as well as learning the reasoning behind a number of the cargo-cult command line tricks that I had.

[1] http://www.bash2zsh.com/

Re:UNIX Tips and Tricks To Save You Time In Terminal by fencepost on Wednesday October 09, 2013 @11:29AM (#6521834)
I find it interesting that there's a whole section on creating bash aliases for git commands, completely ignoring the [alias] section available in .gitconfig (see https://git.wiki.kernel.org/index.php/Aliases for details and a variety of contributed examples).
Re:UNIX Tips and Tricks To Save You Time In Terminal by diggan on Wednesday October 09, 2013 @09:19AM (#6521035)
>"If your terminal window is getting cluttered and you'd like to start from fresh, you can type clear. This will clear your window as if you've just reopened Terminal."

No, it won't. It only looks like it's like reopening the terminal, it won't reload your configs and stuff. Instead of writing "clear", you can do ctrl + r to achieve the same thing.

If you instead really want your terminal to be like reopened, do "reset" instead.

Regarding the history command, combining it with grep is when it becomes really useful. Example, all my latest git commands:

history | grep -i "git"

Re:UNIX Tips and Tricks To Save You Time In Terminal by nfg on Wednesday October 09, 2013 @09:31AM (#6521085)
> you can do ctrl + r to achieve the same thing.

C-r will (usually?) invoke reverse-search-history (http://www.gnu.org/software/bash/manual/html_node/Commands-F...) in bash (and I'm sure some other shells also).

Re:UNIX Tips and Tricks To Save You Time In Terminal by diggan on Wednesday October 09, 2013 @09:33AM (#6521098)
That is absolutely true. I meant super + r.
Re:UNIX Tips and Tricks To Save You Time In Terminal by raphdg on Wednesday October 09, 2013 @09:33AM (#6521101)
I think he meant C-l .
Re:UNIX Tips and Tricks To Save You Time In Terminal by diggan on Wednesday October 09, 2013 @09:41AM (#6521144)
No, I didn't but that's pretty handy since it doesn't hide the new prompt.
Re:UNIX Tips and Tricks To Save You Time In Terminal by slowmover on Wednesday October 09, 2013 @09:57AM (#6521224)
Agreed, and clear won't help if you accidentally cat some binary code and put the terminal into "goofy symbols mode". In that case it's important to remember the reset command, especially if there's something vital running in that terminal and you can't just kill it.

But ctrl-r in bash starts a reverse history search, which is also very useful. It doesn't clear the screen, at least not the way it's configured on my linux machines.

See: http://www.talug.org/events/20030709/cmdline_history.html

Re:UNIX Tips and Tricks To Save You Time In Terminal by clarkm on Wednesday October 09, 2013 @12:39PM (#6522290)
You mean Ctrl + l?
Re:UNIX Tips and Tricks To Save You Time In Terminal by WizzleKake on Wednesday October 09, 2013 @01:17PM (#6522519)
Came here to post this.

Save more time with these: http://www.bigsmoke.us/readline/shortcuts

Re:UNIX Tips and Tricks To Save You Time In Terminal by jwarren on Wednesday October 09, 2013 @09:53AM (#6521203)
Genuinely useful tips, but a slightly misleadingly named article.
Re:UNIX Tips and Tricks To Save You Time In Terminal by ebbv on Wednesday October 09, 2013 @11:27AM (#6521812)
These are really, really newb level "tips" here. I'd consider this more of a "welcome to bash" intro. Are there really people on HN who don't know this stuff?