Skip to content

Instantly share code, notes, and snippets.

@boweiliu
Created April 10, 2018 00:21
Show Gist options
  • Save boweiliu/e6e46da0d67a4c1354b5554782d6da7e to your computer and use it in GitHub Desktop.
Save boweiliu/e6e46da0d67a4c1354b5554782d6da7e to your computer and use it in GitHub Desktop.
Polyglot readme/bash script.

Polyglot readme/bash script. See the raw text of this file for details.

And here is how to include markdown code which will be ignored by bash.

The concept here is to use bash herestring syntax to pass this entire code string as an arugment to true so it gets ignored.

Some tricks are used to get markdown to actually display this -- the end paren on the same line as the herestring declaration, for instance, and the closing block below which provides the end of the bash herestring.

To get bash AND markdown to ignore the final endparen below, we use the shebang.

@dlam
Copy link

dlam commented Sep 28, 2018

My god lol

@fanuch
Copy link

fanuch commented Jun 23, 2022

Unfortunately this fails

[ ! ]: ] 
(
chsh -s $(which zsh)
)

The above rendered shows as:

(
chsh -s $(which zsh)
)

because of the parenthesis.

I was successful with changing the format to backticks (though I would prefer the parentheses):

[ ! ]: ] 
(
chsh -s `which zsh`
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment