Skip to content

Commit 58294b5

Browse files
committed
docs: add shell prompt to Bash examples automatically with PrismJS
1 parent e777e78 commit 58294b5

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

docs/gatsby-browser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { page } from 'cubedev-tracking';
22

3+
import 'prismjs/plugins/command-line/prism-command-line.css'
4+
35
export const onRouteUpdate = ({ location, prevLocation }, pluginOptions = {}) => {
46
//if (process.env.NODE_ENV !== `production` || typeof snowplow !== `function`) {
57
// return null

docs/gatsby-config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ const config = {
7777
options: {
7878
inlineCodeMarker: null,
7979
noInlineHighlight: true,
80+
aliases: {
81+
dotenv: 'bash',
82+
},
83+
prompt: {
84+
user: "user",
85+
host: "localhost",
86+
global: false,
87+
},
8088
},
8189
},
8290
{

docs/static/styles/prism.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,31 @@ pre[class*="language-"] {
152152
cursor: help;
153153
}
154154

155+
.language-bash {
156+
157+
> .command-line-prompt {
158+
border-right: none;
159+
margin-right: 0;
160+
}
161+
162+
> .command-line-prompt > span:before {
163+
color: #999;
164+
content: " ";
165+
display: block;
166+
padding-right: 0.8em;
167+
}
168+
169+
/* Prompt for all users */
170+
> .command-line-prompt > span[data-user]:before {
171+
content: "$";
172+
}
173+
174+
/* Prompt for root */
175+
> .command-line-prompt > span[data-user="root"]:before {
176+
content: "#";
177+
}
178+
179+
> .command-line-prompt > span[data-prompt]:before {
180+
content: attr(data-prompt);
181+
}
182+
}

0 commit comments

Comments
 (0)