Live data from Hacker News

Unix Tricks

cfenollosa.com

21–30 of 166 posts

Re: Unix Tricks

#21
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!

I still prefer "sh" on BSD (particularly OpenBSD). It doesn't have as many knobs to turn nor as many surprises.

Re: Unix Tricks

#22

You might want to try out the more modern fish shell as well: http://fishshell.com/ It makes history searching even easier.

I love fish and have happily been using it for years. Every time it comes up here, though, someone inevitably will complain about compatibility - and I will admit that RVM, for instance, has definitely caused me problems with fish in the past. I guess it depends quite a lot on your particular usage and requirements.

I never got RVM working with fish; unsurprising, seeing as it’s 20k lines of bash. rbenv works well though (with one additional conf line), and chruby was working on support last time I checked.

Re: Unix Tricks

#24

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

Ctrl-P autocompletes from your history too. It works like Ctrl-R but after you've already started typing, if you see what I mean. This might be a zsh thing though.

Ctrl-p in emacs takes you to the previous line. Since readline uses emcs-style notation by default, Ctrl-p takes you to the previous command in history (and Ctrl-n to the next). I don't know about zsh though.

Also, other emacs keys work like back: ctrl-b, meta-b, forward: ctrl-f, meta-f, start of line: ctrl-a, end of line: ctrl-e etc.

Re: Unix Tricks

#25

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.

It doesn't mention either that you can search to the other direction by pressing ctrl-s (usually it also sends the stop signal which should be removed by "stty -ixon"). Very useful if you go past the entry you are looking for.

Re: Unix Tricks

#27
post #17

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.

Here you go, just throw it in your .bashrc: shopt -s histappend export HISTSIZE=100000 export HISTFILESIZE=100000 export HISTCONTROL=ignoredups:erasedups export PROMPT_COMMAND="history -a;history -c;history -r;$PROMPT_COMMAND" I wish I could give credit to where I originally found this but it was ages ago.

Many thanks for this! This has been a thorn in my side for a while but never got round to doing anything about it...

Re: Unix Tricks

#28

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.
Yeah, keeping ctrl pressed in and pressing x followed by e (CTRL + x e) will open up the current line in $EDITOR and when you edit and save, replaces the current line with what you entered in your editor. Really a killer feature.

Re: Unix Tricks

#30

Earlier quoted context omitted.

I love fish and have happily been using it for years. Every time it comes up here, though, someone inevitably will complain about compatibility - and I will admit that RVM, for instance, has definitely caused me problems with fish in the past. I guess it depends quite a lot on your particular usage and requirements.

I never got RVM working with fish; unsurprising, seeing as it’s 20k lines of bash. rbenv works well though (with one additional conf line), and chruby was working on support last time I checked.

There's a wrapper to get RVM working with fish, in case it matters to you now; details here: https://rvm.io/integration/fish
Post reply on HN