# How to use [cmd] tags



## wblock@ (Feb 25, 2013)

[cmd] tags are used to show a command line:
`# ls -lh /etc`

The opening tag takes a parameter that is the prompt, usually # for root, or $ or % for a normal user.  The example above can be entered by typing this:
[cmd="#"]ls -lh /etc[/cmd]

To format a line already entered as a command, drag-select it with the mouse or keyboard and click the [cmd] button.  When asked Please enter the option for your [CMD] tag:, enter the single prompt character.

For proper formatting, do not use more than a single character for the prompt.


----------



## DutchDaemon (Feb 25, 2013)

Or just read  Posting and Editing in the FreeBSD Forums I: proper formatting which is part of your signup email and PM and should be read before posting in the forums 

To wit:

http://forums.freebsd.org/showthread.php?t=8816#cmd


----------



## J65nko (Feb 25, 2013)

The parameter for the *[cmd]* tag is not restricted to a single character, you can use multiple chars if you type the tags manually.
This:

[code][cmd=root@j65nko:/root # ]ls -ol /sbin/init[/cmd]
-r-xr-xr-x  1 root  wheel  schg 791384 Dec  4 10:33 /sbin/init[/code]

will become:


```
[cmd=root@j65nko:/root # ]ls -ol /sbin/init[/cmd]
-r-xr-xr-x  1 root  wheel  schg 791384 Dec  4 10:33 /sbin/init
```


----------



## DutchDaemon (Feb 25, 2013)

That is right. Care should be taken *not* to put an actual command in there though. This may simply vanish or show up double.


----------



## Carpetsmoker (Feb 25, 2013)

It doesn't really matter if you use [cmd=#]ls[/cmd] or just type [cmd]# ls[/cmd]

In HTML, it does:

```
<samp>#</samp> <kbd>ls</kbd>
```

From the HTML spec:


> SAMP: Designates sample output from programs, scripts, etc.
> KBD: Indicates text to be entered by the user.



So from a semantic point of view it matters. Has it actually ever helped anyone? I doubt it.


----------



## DutchDaemon (Feb 25, 2013)

I see (and catch / fix) a lot of [cmd=ls]ls[/cmd] and [cmd]ls[/cmd] type errors, which give sub-optimal results


----------



## wblock@ (Feb 25, 2013)

Those errors are probably due to the very poorly-worded question the mouse version asks: Please enter the option for your `tag:[/file].

Can we change that to ask [file]Please enter the prompt for this command:[/file]?`


----------



## DutchDaemon (Feb 25, 2013)

This does not appear to be determined by the administration panel. It is the default prompt for any forum tag that has the option to have an .. option. Like cmd.


----------



## rupil (Feb 26, 2013)

It is very tricky using tags in this forum with document_colors turned off in Firefox.


----------

