@@ -148,69 +148,17 @@ to set the prompt each time you start up :binary:`~bin.mongosh`.
148
148
Display Line Numbers
149
149
~~~~~~~~~~~~~~~~~~~~
150
150
151
- This code will dynamically update the :binary:`~bin.mongosh` prompt
152
- to display line numbers:
153
-
154
- .. code-block:: javascript
155
-
156
- let cmdCount = 1;
157
- prompt = function() {
158
- return (cmdCount++) + "> ";
159
- }
160
-
161
- The prompt will look like this:
162
-
163
- .. code-block:: javascript
164
-
165
- 1> show collections
166
- 2> use test
167
- 3>
151
+ .. include:: /includes/examples/ex-display-line-numbers.rst
168
152
169
153
Display Database and Hostname
170
154
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171
155
172
- Use a function like this one to display the database and hostname in
173
- the :binary:`~bin.mongosh` prompt:
174
-
175
- .. code-block:: javascript
176
-
177
- {
178
- const hostnameSymbol = Symbol('hostname');
179
- prompt = () => {
180
- if (!db[hostnameSymbol])
181
- db[hostnameSymbol] = db.serverStatus().host;
182
- return `${db.getName()}@${db[hostnameSymbol]}> `;
183
- };
184
- }
185
-
186
- The prompt will look like this:
187
-
188
- .. code-block:: javascript
189
-
190
- admin@centos0722:27502>
156
+ .. include:: /includes/examples/ex-display-dbname-and-hostname.rst
191
157
192
158
Display System Up Time and Document Count
193
159
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194
160
195
- Use a function like this one for a prompt that shows the system uptime
196
- and a count of documents across all collections in the current
197
- database.
198
-
199
- .. code-block:: javascript
200
-
201
-
202
- prompt = function() {
203
- return "Uptime:" + db.serverStatus().uptime +
204
- " Documents:" + db.stats().objects +
205
- " > ";
206
- }
207
-
208
-
209
- The prompt will look like this:
210
-
211
- .. code-block:: javascript
212
-
213
- Uptime:451563 Documents:58 >
161
+ .. include:: /includes/examples/ex-display-system-uptime.rst
214
162
215
163
Behavior
216
164
--------
0 commit comments