Live data from Hacker News

Unix Tricks

cfenollosa.com

81–90 of 166 posts

Re: Unix Tricks

#81
post #64

Missing trick: In bash, "ESC" then "." fetches the last parameter of the previous command. It's invaluable (same as typing "!$" but you get to see and edit it)

It's actually Meta, emulated by an ESC character by the terminal. OSX tip: check "use Option as Meta" in Terminal's preferences, and you can keep Option pressed while you mash ".".

Re: Unix Tricks

#82

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

I like this in my ~/.inputrc

  "\e[A":history-search-backward
  "\e[B":history-search-forward
Type a few characters and hitting the arrow keys will show only commands that match those first few characters.

Re: Unix Tricks

#83
post #64

Missing trick: In bash, "ESC" then "." fetches the last parameter of the previous command. It's invaluable (same as typing "!$" but you get to see and edit it)

There are some great tips/tricks in this document. Too bad it's not in Markdown or something easier on the eyes!

Re: Unix Tricks

#84
post #75

Earlier quoted context omitted.

What I love about this is that if you up-arrow through your past commands, the "sudo !!" shows up as "sudo apt-get update"

Bash substitutions are done prior to execution so your history stays intact. Older open source projects are just amazing for how complete their feature set is.

is this how people feel about religious texts?

Re: Unix Tricks

#85
post #64

Missing trick: In bash, "ESC" then "." fetches the last parameter of the previous command. It's invaluable (same as typing "!$" but you get to see and edit it)

You can also use the following options to see and edit all expansions before running a command:

    shopt -s histverify histreedit

Re: Unix Tricks

#86

Another one: Use dcfldd instead of dd if you want to see how far your dd operation is progressing... dcfldd if=[infile] of=[outfile] sizeprobe=if So. Much. Better. dcfldd also has many other useful options - read the man pages - and note that you'll have to install it from your linux distro's package repo beforehand.

You can also send SIGUSR1 to dd for progress info. From the manpage: Sending a USR1 signal to a running 'dd' process makes it print I/O statistics to standard error and then resume copying. $ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid 18335302+0 records in 18335302+0 records out 9387674624 bytes (9.4 GB) copied, 34.6279 seconds, 271 MB/s

Indeed you can :)

But I prefer not to have to manually keep sending that ;)

Re: Unix Tricks

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

I've been using `history -a`, but what do `history -c` and `history -r` do?

It looks like it clears your shell's history, and then re-populates it from the .bash_history file?

Re: Unix Tricks

#88

Earlier quoted context omitted.

Bash substitutions are done prior to execution so your history stays intact. Older open source projects are just amazing for how complete their feature set is.

is this how people feel about religious texts?

Originally I was gonna write:

>Religious texts don't change over time due to community suggested changes.

Then I caught myself.

Re: Unix Tricks

#89

Earlier quoted context omitted.

Bash substitutions are done prior to execution so your history stays intact. Older open source projects are just amazing for how complete their feature set is.

is this how people feel about religious texts?

You mean my bash fanaticism isn't religious?
Post reply on HN