Jump to content

User:Layer-09/Sandbox/Command: Difference between revisions

From Official NixOS Wiki
Layer-09 (talk | contribs)
.
 
Layer-09 (talk | contribs)
No edit summary
Line 1: Line 1:
<templatestyles src="User:Layer-09/Sandbox/Command.css" />{{#invoke:User:Layer-09/Sandbox/Command.lua|main}}<noinclude>
<templatestyles src="User:Layer-09/Sandbox/Command.css" />{{#invoke:User:Layer-09/Sandbox/Command.lua|main}}<noinclude>
This is a personal command/code block template.
{{Documentation}}
 
'''Usage:'''
<pre>
{{User:Layer-09/Sandbox/Command|1=
your code here
}}
</pre>
 
'''Parameters:'''
* `1`: The code to display.
* `type`: Set to `code` to hide the `$` prefix. Defaults to `command`.
</noinclude>
</noinclude>

Revision as of 08:20, 8 June 2025

<templatestyles src="User:Layer-09/Sandbox/Command.css" />{{#invoke:User:Layer-09/Sandbox/Command.lua|main}}

Template Documentation [edit source| uses| help]

This template displays a command or a block of code with optional line numbers, syntax highlighting, and a one-click copy button.

Usage

Command (with $ prefix)

{{User:Layer-09/Sandbox/Command|1=
nix-shell -E '<span style="color: #c00;">with import <nixpkgs> {}; stdenv.mkDerivation { name = "arm-shell"; buildInputs = [git gnumake gcc gcc-arm-embedded dtc]; }</span>'
git clone git://git.denx.de/u-boot.git
}}

Code (no $ prefix)

To display a block of code without the `$` prompt, use `|type=code`.

{{User:Layer-09/Sandbox/Command|type=code|1=
function example(message) {
  // This is a comment
  console.log(message);
}
}}

Parameters

  • `1`: (Required) The command or code to display. For multi-line content, start the content on a new line. You can use HTML tags like `` for coloring. Use `<` and `>` for literal `<` and `>` characters.
  • `type`: (Optional) The type of block to display.
    • `command` (default): Displays a `$` prefix on each line.
    • `code`: Displays without a `$` prefix. Line numbers still appear for multi-line blocks.