# Pipe Commands for Raycast

URL: https://www.raycast.com/pomdtr/pipe-commands

> Pipe your selection or clipboard to custom scripts defined in any language.

- Install: raycast://extensions/pomdtr/pipe-commands
- Author: [Szdfccb Gxzofw](https://www.raycast.com/pomdtr)
- Installs: 258
- Categories: Developer Tools, Productivity
- Updated: 2022-04-08
- Source: https://github.com/raycast/extensions/tree/a080e6f73629cca8c82d158d0358097af8a96695/extensions/pipe-commands/

## Commands

- **Pipe Selection to Command**: Apply a script on your selection.
- **Pipe Clipboard to Command**: Apply a script on your clipboard.
- **Create Pipe Command**: Generate a new Pipe Command using built-in templates.
- **Manage Pipe Commands**: Edit your Pipe Commands.

## README

### Raycast Pipe Commands

#### Using Pipe Commands

Select / Copy some text and use the `Pipe [Selection, Clipboard] to Command` command.

Depending on the input type, different actions will be shown.

#### Adding Additional Pipe Commands

Use the `Create Pipe command` command to generate a new pipe command template.

The Pipe command syntax is very similar to the [script command syntax](https://github.com/raycast/script-commands/blob/master/README.md), with some caveats:

- The icon field only accepts Raycast API Icons (ex: `Globe`, `Trash`...) instead of emoji and images paths.
- the argument1 only accepts `type` and percentEncoded fields
- The mode field only accept the following options:
  | option    | description                                                  |
  | --------- | ------------------------------------------------------------ |
  | silent    | The last line (if it exists) will be shown in overlaying HUD |
  | fullOuput | The entire output is presented on a separate view            |
  | copy      | The output will be copied to the clipboard                   |
  | replace   | The output will replace the input                            |
- The `iconDark`, `needsConfirmation`, `refreshTime`, `argument2`, `argument3` fields are not supported and will be ignored

#### Pipe Commands Logic

The user input (selection or clipboard) will be passed as the script first argument.

The standard output stream (`stdout`) of the script will replace the current selection, be copied to the clipboard or be passed to a another pipe command depending on the user choice. If the command does not return any output, the selection will be preserved.

If you want to provide a message to the user, use the standard error stream (`stderr`). It will trigger a notification on the user end.

#### Example Commands

##### Google Search

```bash
#!/bin/bash

# @raycast.title Google Search
# @raycast.packageName Web Searches
# @raycast.mode silent
# @raycast.icon Globe
# @raycast.argument1 {"type": "text", "percentEncoded": true}

# Open the url in the default browser
open "https://www.google.com/search?q=$1"
```

##### Format JSON

```python
#!/bin/bash

# @raycast.title Prettify JSON
# @raycast.packageName Developer Utils
# @raycast.mode replace
# @raycast.icon Hammer
# @raycast.argument1 {"type": "text"}

python3 -m json.tool --indent 2 <<< "$1"
```
