[PYTHON] Code block when writing console (shell) command execution in Qiita

Executing console commands in Qiita is something like this, for example.

brew install node

You might write something like this so that you can see it as a prompt.

$ brew install node

Until now, I used to say sh or none to the code block, and I didn't care if the highlights were a little strange, but there were times when it looked too terrible, so it's really annoying, so it's really annoying. It's annoying, but I thought I'd check it out. Oh, it's annoying. I want to live more comfortably. I want a lot of money.

The one you specify for the console (shell)

Maybe there are three main languages to specify for this purpose. I think it's easiest to put the appearance as it is, so I will do so.

--sh (bash, ksh) ・ ・ ・ Shell script --console ・ ・ ・ Single command, one liner --shell-session ・ ・ ・ When you want to write the session as it is including the output

Is it beautiful to use properly?

Well, I'm talking about Qiita's, rather than the highlighting, lexer in the Pygments library. The difference from the kobito preview is that the library you are using is different.

sh

Specify sh. It is the same even if you specify bash, ksh.

5t111111@ganryu $ brew install node
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.28.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring node-0.10.28.mavericks.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> make install
==> /usr/local/bin/npm update npm -g
==> Summary
?  /usr/local/Cellar/node/0.10.28: 1547 files, 18M
5t111111@ganryu $ which node
/usr/local/bin/node
5t111111@ganryu $ node -v
v0.10.28
brew install node
$ brew install node
# tail -f /var/log/messages

class pygments.lexers.shell.BashLexer Short names: bash, sh, ksh Filenames: *.sh, *.ksh, *.bash, *.ebuild, *.eclass, .bashrc, bashrc, .bash*, bash* MIME types: application/x-sh, application/x-shellscript

http://pygments.org/docs/lexers

console

Specify console.

5t111111@ganryu $ brew install node
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.28.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring node-0.10.28.mavericks.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> make install
==> /usr/local/bin/npm update npm -g
==> Summary
?  /usr/local/Cellar/node/0.10.28: 1547 files, 18M
5t111111@ganryu $ which node
/usr/local/bin/node
5t111111@ganryu $ node -v
v0.10.28
brew install node
$ brew install node
# tail -f /var/log/messages

class pygments.lexers.shell.BashSessionLexer Short names: console Filenames: *.sh-session MIME types: application/x-shell-session Lexer for simplistic shell sessions.

shell-session

Specify shell-session.

5t111111@ganryu $ brew install node
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/node-0.10.28.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring node-0.10.28.mavericks.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> make install
==> /usr/local/bin/npm update npm -g
==> Summary
?  /usr/local/Cellar/node/0.10.28: 1547 files, 18M
5t111111@ganryu $ which node
/usr/local/bin/node
5t111111@ganryu $ node -v
v0.10.28
brew install node
$ brew install node
# tail -f /var/log/messages

class pygments.lexers.shell.ShellSessionLexer Short names: shell-session Filenames: *.shell-session MIME types: application/x-sh-session Lexer for shell sessions that works with different command prompts

Recommended Posts

Code block when writing console (shell) command execution in Qiita
A memorandum when writing experimental code ~ Logging in python
External command execution in Python
curl command show http status code in response (#Linux #Shell)
Run shell command / python in R
When writing a program in Python
What Emacs users should know when writing python code in Sublime Text
Behavior when returning in the with block
Shell command to visualize line feed code
How to pass the execution result of a shell command in a list in Python