Template:Commands: Difference between revisions

From NixOS Wiki
imported>Samueldr
m Removes whitespace from page, mediawiki is fussy with new lines.
Sdht0 (talk | contribs)
Add proper sections
 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
{{META Pipe Character}}
{{META Pipe Character}}


===Usage===
== Usage ==


Take care of always aligning the {{ic|$}} to the left.
Take care of always aligning the {{ic|$}} to the left.
Line 13: Line 13:
}}</nowiki>}}
}}</nowiki>}}


===Example===
{{bc|<nowiki>{{Commands|$ cat /proc/cpuinfo {{!}} grep '^model name' {{!}} head -n1}}</nowiki>}}
 
{{bc|<nowiki>{{Commands|&lt;nowiki>
# Disregard useless use of cat
$ cat /proc/cpuinfo | grep '^model name' | head -n1
&lt;/nowiki>}}</nowiki>}}
 
== Example ==
{{Commands|$ command-not-found}}
{{Commands|$ command-not-found}}


Line 20: Line 27:
$ other-command
$ other-command
}}
}}
Example with wrong alignment
{{Commands|
$ command-not-found
$ other-command
$ final-command
}}
====Escaping pipe====
''Look at the source to see usage.''


{{Commands|$ cat /proc/cpuinfo {{!}} grep '^model name' {{!}} head -n1}}
{{Commands|$ cat /proc/cpuinfo {{!}} grep '^model name' {{!}} head -n1}}
Line 41: Line 36:


</noinclude><includeonly><pre<noinclude></noinclude>
</noinclude><includeonly><pre<noinclude></noinclude>
   style="
   style="{{META Commands Style}}"
    background-color: #4D4D4D;
    color: #FCFCFC;
    padding: 0.4em;
    border: 1px solid #232629;
  "
>{{{code|{{{1|{{META Error}}}}}}}}</pre<noinclude></noinclude>></includeonly><noinclude><!-- The &lt;noinclude>&lt;/noinclude> hack is needed to allow wiki markup inside the pre tags; reference: http://www.gossamer-threads.com/lists/wiki/mediawiki/118688#118688 --></noinclude>
>{{{code|{{{1|{{META Error}}}}}}}}</pre<noinclude></noinclude>></includeonly><noinclude><!-- The &lt;noinclude>&lt;/noinclude> hack is needed to allow wiki markup inside the pre tags; reference: http://www.gossamer-threads.com/lists/wiki/mediawiki/118688#118688 --></noinclude>

Latest revision as of 21:26, 6 April 2024

This page is a template. It should be used as part of other articles. For more information, see Help:Template.

Please do not experiment with this template; you could ruin all pages using this template. If you want to edit this template, copy the text to Template:Sandbox, edit and test it there, and copy it back when it works.

Feel free to discuss this template in the talk page.

If you wanted to create a new page instead, use the search box to search for the title of the new page you want to create and follow the link Create the page "XYZ" on this wiki! in the results page. An alternative is to create a dangling link to the new page from an existing page. A final option is to directly visit the expected URL of the page.

Special note

The pipe character cannot be used as is within the template, as it is a special characters for templates.

It can be included using the magic word {{!}}.

Alternatively, it is possible to instead surround the contents in <nowiki> tags.

Usage

Take care of always aligning the $ to the left.

{{Commands|$ command-not-found}}
{{Commands|
$ command-not-found
$ other-command
}}
{{Commands|$ cat /proc/cpuinfo {{!}} grep '^model name' {{!}} head -n1}}
{{Commands|<nowiki>
# Disregard useless use of cat
$ cat /proc/cpuinfo | grep '^model name' | head -n1
</nowiki>}}

Example

$ command-not-found
$ command-not-found
$ other-command
$ cat /proc/cpuinfo | grep '^model name' | head -n1
# Disregard useless use of cat
$ cat /proc/cpuinfo | grep '^model name' | head -n1