Live data from Hacker News

Unix Commands I Wish I’d Discovered Years Earlier

spin.atomicobject.com

121–130 of 259 posts

Re: Unix Commands I Wish I’d Discovered Years Earlier

#121

Earlier quoted context omitted.

Also in that vein on Mac it's worth having a look at Alfred http://alfredapp.com

Alread rocks. You can develop workflows for common groups of tasks and it integrates well with iTunes, 1Password, Terminal and other system actions/apps.

It really does. My computer would be like 30% less usable without it. The file search is particularly amazing.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#123
post #122
post #92

Earlier quoted context omitted.

You can turn that off with: cal | cat

can you please explain how this works?

it's quite a common pattern in commandline apps to check if the stdout is a tty or not, and do things differently if so. So when you pipe it through `cat', it does the no-fancy-included output, much like the colouring that `ls' will apply interactively, but not when piped/redirected.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#125
post #19
post #5

Earlier quoted context omitted.

Aliasing to 'cal -3' can also be good if you want a little continuity.

The -3 arg is not available on OS X. Odd, since it's been in BSD Unix since forever. http://www.freebsd.org/cgi/man.cgi?query=cal

It's hardly ubiquitous.

NetBSD has had it for 11 years. FreeBSD has had it for three years and six months. DragonFly doesn't have it, OpenBSD doesn't have it...

http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/cal/cal.c?re... http://svnweb.freebsd.org/base?view=revision&revision=204697

Re: Unix Commands I Wish I’d Discovered Years Earlier

#128
post #58

Earlier quoted context omitted.

The single most useful thing about ssh to me is that it connects stdout/in across the channel (this is behavior inherited from rsh). This allows for e.g.: % (cd /foo; tar cpf - .) | ssh bar \(cd /baz\; tar xpf -\) Or: % cat ~/.ssh/id_rsa.pub | ssh bar tee -a .ssh/authorized_keys

Forgive my ignorance, but I don't know what what it means to connect "across the channel", but it sounds important. Do you know a link that explains the concept? I've failed to Google it.

It means that whatever you put into the ssh process's STDIN gets sent to the STDIN of the remote process. For example you can do this:

    tar cj $bigdir | ssh host 'tar xj'
That creates a tar.bz2 archive on your machine, sends it over ssh to the remote host, where it's unpacked. Ad hoc compressed and encrypted file transfers made easy.

Re: Unix Commands I Wish I’d Discovered Years Earlier

#129
post #122

Earlier quoted context omitted.

can you please explain how this works?

it's quite a common pattern in commandline apps to check if the stdout is a tty or not, and do things differently if so. So when you pipe it through `cat', it does the no-fancy-included output, much like the colouring that `ls' will apply interactively, but not when piped/redirected.

It's important for grepping and sedding - the colors are escape codes and would mess with your regular expressions otherwise (you want to find foobar , but bar was blue so you got foo\e[1;34mbar\e[0m instead, and it doesn't match with foobar).

Re: Unix Commands I Wish I’d Discovered Years Earlier

#130
Command line globbing! For the uninitiated:

Let's say my pwd is `/home/projects` and i want to edit `/home/projects/a_huge_sprawling_app/940j_394/lol/flight_controller.rb`

  `vim **/flight_controller.rb` 
opens our flight_controller.rb straight away. In terms of effort, this allows you to basically omit a `find -name` when you're in a rush to edit some damn file where the hell is it again damn we need to reevaluate this directory str...

----

Double bang to re-use your last terminal entry. One great use, taking all the pain out of forgetting your sudos

  `rm -rf /var/log`
  rm: cannot remove `/var/log': Permission denied
  `sudo !!`
All evidence of wrongdoing is now destroyed.

-----

Ok, here is an awesome one for users of the ultimate cloud IDE: Vim.

In your local ~/.ssh/config:

  `ForwardX11 yes`
  `SendEnv WINDOWID`
In your remote server's /etc/ssh/sshd_config:

  `AcceptEnv WINDOWID`
In your vimrc:

  `set clipboard=unnamedplus`
This has the effect of seamless yank and paste between local and remote vim sessions, no need for ctrl+shift+v.

I love linux.

Post reply on HN