# Command

The command shortcode generates terminal output for either Bash, PowerShell, or SQL shell languages.

## Overview

Added in v0.5.0

The `command` shortcode generates terminal output for either `bash`, `powershell`, or `sql` shell languages. The following example generates a block with a default bash command prompt.

```markdown
{{< command >}}
export MY_VAR=123
{{< /command >}}
```

## Examples

Change the style and language of your command prompt with shortcode arguments.

### Bash

Specify `user` and `host` to add the user context to the prompt. In addition, use `(out)` to specify an output line and use `\` to denote a line continuation.

```markdown
{{< command user="user" host="localhost" >}}
export MY_VAR=123
echo "hello"
(out)hello
echo one \
two \
three
(out)one two three
echo "goodbye"
(out)goodbye
{{< /command >}}
```

### PowerShell

Set the `shell` argument to `powershell` to generate a PowerShell terminal. Override the `prompt` to add a directory if needed. Use the backtick `` ` `` symbol to denote a line continuation.

```markdown
{{< command prompt="PS C:\Users\User>" shell="powershell" >}}
Write-Host `
'Hello' `
'from' `
'PowerShell!'
(out)Hello from PowerShell!
Write-Host 'Goodbye from PowerShell!'
(out)Goodbye from PowerShell!
{{< /command >}}
```

### SQL

Set the `shell` argument to `sql` to generate a SQL terminal. Use the `(con)` suffix to denote a line continuation.

```markdown
{{< command prompt="mysql>" shell="sql" >}}
set @my_var = 'foo';
set @my_other_var = 'bar';
CREATE TABLE people ((con)
first_name VARCHAR(30) NOT NULL,(con)
last_name VARCHAR(30) NOT NULL(con)
);
(out)Query OK, 0 rows affected (0.09 sec)
insert into people(con)
values ('John', 'Doe');
(out)Query OK, 1 row affected (0.02 sec)
select *(con)
from people(con)
order by last_name;
(out)+------------+-----------+
(out)| first_name | last_name |
(out)+------------+-----------+
(out)| John       | Doe       |
(out)+------------+-----------+
(out)1 row in set (0.00 sec)
{{< /command >}}
```

## Styling

The file `assets/scss/components/_command.scss` defines the Hinode-specific styling of the `command` shortcode.

```scss
/* Adapted from PrismJS 1.29.0
https://prismjs.com/download.html#themes=prism&plugins=command-line */

/**
 * prism.js default theme for JavaScript, CSS and HTML
 * Based on dabblet (http://dabblet.com)
 * @author Lea Verou
 */

.command-line-prompt {
    border-right: 1px solid #999;
    display: block;
    float: left;
    font-size: 100%;
    letter-spacing: -1px;
    margin-right: 1em;
    pointer-events: none;
    text-align: right;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.command-line-prompt > span::before {
    opacity: 0.7;
    content: " ";
    display: block;
    padding-right: 0.8em;
}

.command-line-prompt > span[data-prompt]::before {
    content: attr(data-prompt);
}

.command-line-prompt > span[data-continuation-prompt]::before {
    content: attr(data-continuation-prompt);
}

.command-line span.token.output {
    /* Make shell output lines a bit lighter to distinguish them from shell commands */
    opacity: 0.7;
}
```

## Arguments

The shortcode supports the following arguments:

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `class` | string |  |  | Class attributes of the element. It supports Bootstrap attributes to modify the styling of the element. |
| `host` | string |  |  | Host to add to the prompt, e.g. `localhost`. |
| `prompt` | string |  |  | Prompt override, e.g. `PS C:\Users\User>`. |
| `shell` | select |  | `bash` | Type of shell. Supported values: [`bash`, `powershell`, `sql`]. |
| `user` | string |  |  | User to add to the prompt, e.g. `user`. |

