Including a command within the wiki: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(Created page with "<languages /> To include a command within the wiki, you should use the <nowiki>{{Commande}}</nowiki> template. This template detects the '''bash''' syntax. For example, the co...")
 
No edit summary
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages />
<languages />
To include a command within the wiki, you should use the <nowiki>{{Commande}}</nowiki> template. This template detects the '''bash''' syntax. For example, the code
 
<translate>
<!--T:1-->
To include a command within the wiki, you should use the <nowiki>{{Command}}</nowiki> template. This template detects the '''bash''' syntax. For example, the code
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
{{Command|cd src; make && make install; cd ..}}
{{Command|cd src; make && make install; cd ..}}
Line 7: Line 10:
{{Command|cd src; make && make install; cd ..}}
{{Command|cd src; make && make install; cd ..}}


== Including a "{{=}}" within a command ==
== Special characters "{{=}}" and "{{!}}" == <!--T:2-->
Since <nowiki>{{Command}}</nowiki> is a template, the "=" signs are interpreted by the wiki. To include an equality sign, use the [[Modèle:=|meta-template <nowiki>{{=}}</nowiki>]]. For example, the code:
Since <nowiki>{{Command}}</nowiki> is a template, the "=" and "|" signs are interpreted by the wiki.
 
<!--T:8-->
To include an equality sign, use the [[Template:=|meta-template <nowiki>{{=}}</nowiki>]]. For example, the code:
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
{{Command|./configure --prefix{{=}}$HOME && make && make install}}
{{Command|./configure --prefix{{=}}$HOME && make && make install}}
Line 14: Line 20:
results in:
results in:
{{Command|./configure --prefix{{=}}$HOME && make && make install}}
{{Command|./configure --prefix{{=}}$HOME && make && make install}}
To include a pipe symbol, use <nowiki>{{!}}</nowiki>.


== Including a set of commands ==
== Including a set of commands == <!--T:3-->
You can use the <nowiki>{{Commands}}</nowiki> template to include a set of commands. You may then write each command on a separate line, and prepend the '''|''' character in front of each command. For example, the code
You can use the <nowiki>{{Commands}}</nowiki> template to include a set of commands. You may then write each command on a separate line, and prepend the '''|''' character in front of each command. For example, the code
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
Line 33: Line 40:
}}
}}


== Modifying the command prompt ==
== Modifying the command prompt == <!--T:4-->
If you want to modify the command prompt, you may do it by including a ''prompt'' argument to the template. For example,  
If you want to modify the command prompt, you may do it by including a ''prompt'' argument to the template. For example,  
<syntaxhighlight lang=text>{{Command|prompt=[name@briaree ~]|cd src; make && make install; cd ..}}</syntaxhighlight>
<syntaxhighlight lang=text>{{Command|prompt=[name@briaree ~]|cd src; make && make install; cd ..}}</syntaxhighlight>
Line 39: Line 46:
{{Command|prompt=[name@briaree ~]|cd src; make && make install; cd ..}}
{{Command|prompt=[name@briaree ~]|cd src; make && make install; cd ..}}


<!--T:5-->
In the same way,  
In the same way,  
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
Line 58: Line 66:
}}
}}


== Displaying the result of a command ==
== Displaying the result of a command == <!--T:6-->
You can display the result of a command (and only one) by adding the option <tt>result</tt>. For example,  
You can display the result of a command (and only one) by adding the option <tt>result</tt>. For example,  
<syntaxhighlight>
<syntaxhighlight>
Line 75: Line 83:
/lustre2/home        516T  340T  150T  70% /home
/lustre2/home        516T  340T  150T  70% /home
}}
}}
</translate>

Latest revision as of 17:57, 15 February 2019

Other languages:

To include a command within the wiki, you should use the {{Command}} template. This template detects the bash syntax. For example, the code

{{Command|cd src; make && make install; cd ..}}

results in:

Question.png
[name@server ~]$ cd src; make && make install; cd ..

Special characters "=" and "|"

Since {{Command}} is a template, the "=" and "|" signs are interpreted by the wiki.

To include an equality sign, use the meta-template {{=}}. For example, the code:

{{Command|./configure --prefix{{=}}$HOME && make && make install}}

results in:

Question.png
[name@server ~]$ ./configure --prefix=$HOME && make && make install

To include a pipe symbol, use {{!}}.

Including a set of commands

You can use the {{Commands}} template to include a set of commands. You may then write each command on a separate line, and prepend the | character in front of each command. For example, the code

{{Commands
|cd src
|make
|make install
|cd ..
}}

results in:

[name@server ~]$ cd src
[name@server ~]$ make
[name@server ~]$ make install
[name@server ~]$ cd ..


Modifying the command prompt

If you want to modify the command prompt, you may do it by including a prompt argument to the template. For example,

{{Command|prompt=[name@briaree ~]|cd src; make && make install; cd ..}}

results in

Question.png
[name@briaree ~] cd src; make && make install; cd ..

In the same way,

{{Commands
|prompt=[name@briaree $]
|cd src
|make
|make install
|cd ..
}}

results in

[name@briaree $] cd src
[name@briaree $] make
[name@briaree $] make install
[name@briaree $] cd ..


Displaying the result of a command

You can display the result of a command (and only one) by adding the option result. For example,

{{Command
|df -h .
|result=
Sys. de fich.         Tail. Occ. Disp. %Occ. Monté sur
/lustre2/home         516T  340T  150T  70% /home
}}

results in :

Question.png
[name@server ~]$ df -h .
Sys. de fich.         Tail. Occ. Disp. %Occ. Monté sur
/lustre2/home         516T  340T  150T  70% /home