silasjmatson
silasjmatson

Reputation: 1814

Possible to use output of one command as an argument for an alias?

I have zshell, and an alias for sublime text 2

I often look at the source of bundled gems, so I'll run this

bundle show gemname 

-> outputs the path which I have to copy

subl path/to/gem

I want to pass the output of the first command into the alias as it's argument.

Is something like this possible with aliases:

bundle show gemname | subl

Or some variation thereof?

I'm not very familiar with the full suite of unix command line capability.

Upvotes: 0

Views: 82

Answers (1)

Joshua D. Boyd
Joshua D. Boyd

Reputation: 4856

I believe that this should do exactly what you want:

subl `bundle show gemname`

Note the backtick characters, which is usually the key to the left of the 1 key and also below the esc key on a typical keyboard. This says to run the command in the backticks and use it's output in the outer command.

Upvotes: 3

Related Questions