Live data from Hacker News

Unix Tricks

cfenollosa.com

31–40 of 166 posts

Re: Unix Tricks

#32

You know what I hate? My history isn't aggregated in real time across all my Mac OS X terminal windows. You know what else I hate? Typing in long commands in the Mac OS X terminal and then them wrapping weirdly. Especially when I hit the up arrow to go back in my terminal history.

>You know what else I hate? Typing in long commands in the Mac OS X terminal and then them wrapping weirdly.

Are you escaping your color codes in PS1 correctly?

Bad:

    PS1="\033[1;32m \w \033[m $"
Good (notice the extra \[ and \]):

    PS1="\[\033[1;32m\] \w \[\033[m\] $"

Re: Unix Tricks

#33
post #29

man hier is pretty cool. It explains the root directory structure of the system.

TIL. As a long-time DOS user that often gets a bit lost on Unix systems I cannot stress how awesome it is to have found out about this!

Re: Unix Tricks

#35

You know what I hate? My history isn't aggregated in real time across all my Mac OS X terminal windows. You know what else I hate? Typing in long commands in the Mac OS X terminal and then them wrapping weirdly. Especially when I hit the up arrow to go back in my terminal history.

>You know what else I hate? Typing in long commands in the Mac OS X terminal and then them wrapping weirdly. Are you escaping your color codes in PS1 correctly? Bad: PS1="\033[1;32m \w \033[m $" Good (notice the extra \[ and \]): PS1="\[\033[1;32m\] \w \[\033[m\] $"

This. Right Here. For the longest time I could not figure out why my Ctrl-r (history) was so messed up.

Re: Unix Tricks

#36
post #29

man hier is pretty cool. It explains the root directory structure of the system.

Nice to see something I've gradually learned about by gut feel summarized.

Why do some distributions use /opt a lot while others don't seem to use it at all?

Re: Unix Tricks

#37

Ctrl-R is by far the most useful one for me.

The article doesn't say, so it's worth mentioning that you can type ctrl-R multiple times to search further back into command history.

I use C-r constantly. But sometimes I need to find a command, and then edit it before running it. What is the proper way to exit "search mode" and go into the normal "edit" mode?

Re: Unix Tricks

#38
post #3

It's amazing how many years I've been using bash and I still have things to discover. Ctrl-x Ctrl-e nice tip!

In bash fc will open your $EDITOR with the last command you just typed. Just like Ctrl-x Ctrl-e but you don't need a command in place to edit.

Re: Unix Tricks

#39
post #7

One to add: Unfreezing terminal after pressing Ctrl+S by accident. Press Ctrl-Q.

One that I needed to use a lot in the old days, and still occasionally need:

If your font is all messed up, echo C-v C-o. C-v puts you into a literal mode, and C-o gets you back into the normal character set. (You probably got there by emitting a C-p at some point.)

Post reply on HN