Difference between revisions of "Template:Cli"

From wiki.emacinc.com
Jump to: navigation, search
m (Tweaked)
m (Tweaked.)
 
(10 intermediate revisions by the same user not shown)
Line 3: Line 3:
  
 
This template displays the passed argument, <code>cmd</code>, at a simulated command line.
 
This template displays the passed argument, <code>cmd</code>, at a simulated command line.
 +
 +
NOTE: The <code>indent</code> argument is now available.  To indent the line, pass <code>indent=2</code> or similar:
 +
 +
<nowiki>{{cli | indent=2 | ls -lah}}</nowiki>
 +
 +
to produce:
 +
 +
{{cli | indent=2 | ls -lah}}
 +
 +
-----
  
 
Use it like this:
 
Use it like this:
  
 
  <nowiki>{{cli | ls -la}}</nowiki>
 
  <nowiki>{{cli | ls -la}}</nowiki>
 +
 +
to produce:
 +
 +
{{cli | ls -la}}
 +
 +
 +
-----
  
 
Choose the PWD (Present Working Directory) like this:
 
Choose the PWD (Present Working Directory) like this:
  
 
  <nowiki>{{cli | ls -la | pwd=/home/user}}</nowiki>
 
  <nowiki>{{cli | ls -la | pwd=/home/user}}</nowiki>
 +
 +
to produce:
 +
 +
{{cli | ls -la | pwd=/home/user}}
 +
 +
 +
-----
  
 
Choose the hostname like this:
 
Choose the hostname like this:
  
 
  <nowiki>{{cli | ls -la | hostname=desktop}}</nowiki>
 
  <nowiki>{{cli | ls -la | hostname=desktop}}</nowiki>
 +
 +
to produce:
 +
 +
{{cli | ls -la | hostname=desktop}}
 +
 +
 +
-----
  
 
Choose the username like this:
 
Choose the username like this:
Line 20: Line 51:
 
  <nowiki>{{cli | ls -la | username=developer}}</nowiki>
 
  <nowiki>{{cli | ls -la | username=developer}}</nowiki>
  
----
+
to produce:
----
+
 
</noinclude><div style="padding-bottom:2px;padding-top:2px;margin-left:0.3%;margin-right:2%;padding-left:3px;padding-right:5px;background-color:#000000;border-radius:2px;box-shadow:1px 1px 1px 0px;">{{clitxt|{{#ifeq:{{{username|}}}|{{{username|-}}}|#00aa00|#aa0000}}}}{{#ifeq:{{{username|}}}|{{{username|-}}}|{{{username}}}|root}}{{clitxts}}{{clitxt|#ffffff}}@{{clitxts}}{{clitxt|#00aaaa}}{{#ifeq:{{{hostname|}}}|{{{hostname|-}}}|{{{hostname}}}|som9x25}}{{clitxts}}{{clitxt|#ffffff}}:{{clitxts}}{{clitxt|#54ffff}}{{#ifeq:{{{pwd|}}}|{{{pwd|-}}}|{{{pwd}}}|~}}{{clitxts}}{{clitxt|#ffff55}}#{{clitxts}}{{clitxt}} {{{1}}}{{clitxts}}</div>
+
{{cli | ls -la | username=developer}}
 +
 
 +
 
 +
-----
 +
 
 +
Combine them like this:
 +
 
 +
<nowiki>{{cli | ls -la | username=developer | hostname=desktop | pwd=/usr/local/bin}}</nowiki>
 +
 
 +
to produce:
 +
 
 +
{{cli | ls -la | username=developer | hostname=desktop | pwd=/usr/local/bin}}
 +
 
 +
 
 +
-----
 +
 
 +
Use the <code><nowiki>{{!}}</nowiki></code> template to pass a pipe character for display, like this:
 +
 
 +
<nowiki>{{cli | username=developer | hostname=desktop | pwd=/usr/local/bin | ifconfig {{!}} grep eth0 }}</nowiki>
 +
 
 +
to produce:
 +
 
 +
{{cli | username=developer | hostname=desktop | pwd=/usr/local/bin | ifconfig {{!}} grep eth0 }}
 +
 
 +
 
 +
-----
 +
 
 +
Use the <code>&amp;#x3d;</code> HTML tag in place of an equals sign:
 +
 
 +
<nowiki>{{cli | username=joeknows | hostname=squat | pwd=/usr/share/files | export PS1&amp;#x3d;'\[\e[0;32m\]\u\[\033[01;37m\]@\[\e[0;36m\]\h\[\e[0;37m\]:\[\e[01;36m\]\w\[\e[01;33m\] \$\[\e[m\] ' }}</nowiki>
 +
 
 +
to produce:
 +
 
 +
{{cli | username=joeknows | hostname=squat | pwd=/usr/share/files | export PS1&#x3d;'\[\e[0;32m\]\u\[\033[01;37m\]@\[\e[0;36m\]\h\[\e[0;37m\]:\[\e[01;36m\]\w\[\e[01;33m\] \$\[\e[m\] ' }}
 +
 
 +
 
 +
-----
 +
To deal with double closing curly braces, surround them with the <code>&lt;nowiki&gt;</code> tag:
 +
 
 +
<nowiki>{{cli | username=some | hostname=body | pwd=/stop/me | echo 'My name is ${HOSTNAME}' {{!}} sed 's/is/was/g' {{!}} awk '{ print $1 $4 '$(basename /etc/profile)' '$(echo ${PS${SHLVL&lt;nowiki&gt;}}&lt;/nowiki&gt;' '}' }}</nowiki>
 +
 
 +
to produce:
 +
 
 +
{{cli | username=some | hostname=body | pwd=/stop/me | echo 'My name is ${HOSTNAME}' {{!}} sed 's/is/was/g' {{!}} awk '{ print $1 $4 '$(basename /etc/profile)' '$(echo ${PS${SHLVL<nowiki>}}</nowiki>' '}' }}
 +
 
 +
 
 +
</noinclude><includeonly><div style="padding-bottom:2px; padding-top:2px; margin-left:{{#ifeq:{{{indent|}}}|{{{indent|-}}}|{{#expr: 0.2 + {{{indent}}} * 2}}%|0.2%}}; margin-right:5.2%; padding-left:3px; padding-right:5px; background-color:#000000; border-radius:2px; box-shadow:1px 2px 11px #888;">{{clitxt|{{#ifeq:{{{username|}}}|{{{username|-}}}|#00aa00|#aa0000}}}}{{#ifeq:{{{username|}}}|{{{username|-}}}|{{{username}}}|root}}{{clitxts}}{{clitxt|#ffffff}}@{{clitxts}}{{clitxt|#00aaaa}}{{#ifeq:{{{hostname|}}}|{{{hostname|-}}}|{{{hostname}}}|som9x25}}{{clitxts}}{{clitxt|#ffffff}}:{{clitxts}}{{clitxt|#54ffff}}{{#ifeq:{{{pwd|}}}|{{{pwd|-}}}|{{{pwd}}}|~}}{{clitxts}}{{clitxt|#ffff55}}#{{clitxts}}{{clitxt}} {{{1}}}{{clitxts}}</div></includeonly>

Latest revision as of 12:11, 20 November 2015

The CLI Template

This template displays the passed argument, cmd, at a simulated command line.

NOTE: The indent argument is now available. To indent the line, pass indent=2 or similar:

{{cli | indent=2 | ls -lah}}

to produce:

root@som9x25:~# ls -lah

Use it like this:

{{cli | ls -la}}

to produce:

root@som9x25:~# ls -la



Choose the PWD (Present Working Directory) like this:

{{cli | ls -la | pwd=/home/user}}

to produce:

root@som9x25:/home/user# ls -la



Choose the hostname like this:

{{cli | ls -la | hostname=desktop}}

to produce:

root@desktop:~# ls -la



Choose the username like this:

{{cli | ls -la | username=developer}}

to produce:

developer@som9x25:~# ls -la



Combine them like this:

{{cli | ls -la | username=developer | hostname=desktop | pwd=/usr/local/bin}}

to produce:

developer@desktop:/usr/local/bin# ls -la



Use the {{!}} template to pass a pipe character for display, like this:

{{cli | username=developer | hostname=desktop | pwd=/usr/local/bin | ifconfig {{!}} grep eth0 }}

to produce:

developer@desktop:/usr/local/bin# ifconfig | grep eth0



Use the &#x3d; HTML tag in place of an equals sign:

{{cli | username=joeknows | hostname=squat | pwd=/usr/share/files | export PS1&#x3d;'\[\e[0;32m\]\u\[\033[01;37m\]@\[\e[0;36m\]\h\[\e[0;37m\]:\[\e[01;36m\]\w\[\e[01;33m\] \$\[\e[m\] ' }}

to produce:

joeknows@squat:/usr/share/files# export PS1='\[\e[0;32m\]\u\[\033[01;37m\]@\[\e[0;36m\]\h\[\e[0;37m\]:\[\e[01;36m\]\w\[\e[01;33m\] \$\[\e[m\] '



To deal with double closing curly braces, surround them with the <nowiki> tag:

{{cli | username=some | hostname=body | pwd=/stop/me | echo 'My name is ${HOSTNAME}' {{!}} sed 's/is/was/g' {{!}} awk '{ print $1 $4 '$(basename /etc/profile)' '$(echo ${PS${SHLVL<nowiki>}}</nowiki>' '}' }}

to produce:

some@body:/stop/me# echo 'My name is ${HOSTNAME}' | sed 's/is/was/g' | awk '{ print $1 $4 '$(basename /etc/profile)' '$(echo ${PS${SHLVL}}' '}'