|
5 | 5 | <link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
|
6 | 6 | <link href="https://learnbyexample.github.io"/>
|
7 | 7 | <generator uri="https://www.getzola.org/">Zola</generator>
|
8 |
| - <updated>2023-03-14T00:00:00+00:00</updated> |
| 8 | + <updated>2023-03-15T00:00:00+00:00</updated> |
9 | 9 | <id>https://learnbyexample.github.io/atom.xml</id>
|
10 | 10 | <entry xml:lang="en">
|
11 | 11 | <title>Vim tip 23: editing lines filtered by a pattern</title>
|
@@ -1171,24 +1171,30 @@ Specifying a greater than <code>0</code> start index when using
|
1171 | 1171 | <entry xml:lang="en">
|
1172 | 1172 | <title>Interactive Linux CLI Text Processing Exercises</title>
|
1173 | 1173 | <published>2022-12-09T00:00:00+00:00</published>
|
1174 |
| - <updated>2022-12-09T00:00:00+00:00</updated> |
| 1174 | + <updated>2023-03-15T00:00:00+00:00</updated> |
1175 | 1175 | <link rel="alternate" href="https://learnbyexample.github.io/interactive-linux-cli-exercises/" type="text/html"/>
|
1176 | 1176 | <id>https://learnbyexample.github.io/interactive-linux-cli-exercises/</id>
|
1177 | 1177 | <content type="html"><p>Having an interactive program that automatically loads questions and checks the solution is wonderful to have while learning a topic. This <a href="https://github.com/learnbyexample/TUI-apps/tree/main/CLI-Exercises">TUI app</a> has 40 beginner to intermediate level exercises for Linux CLI text processing tools.</p>
|
1178 | 1178 | <p align="center"><img src="https://raw.githubusercontent.com/learnbyexample/TUI-apps/main/CLI-Exercises/cli_exercises.png" alt="Sample screenshot for CLI exercises" loading="lazy" /></p>
|
1179 | 1179 | <span id="continue-reading"></span><br>
|
1180 | 1180 | <h2 id="installation">Installation<a class="zola-anchor" href="#installation" aria-label="Anchor link for: installation">🔗</a></h2>
|
1181 | 1181 | <p>Last month, I started learning a Python TUI framework called <a href="https://textual.textualize.io/">Textual</a>. After working on a <a href="https://github.com/learnbyexample/TUI-apps/tree/main/SquareTicTacToe">4x4 board game</a>, I made an interactive app to help you test your CLI text processing skills with 40 beginner to intermediate level exercises. The app is fairly basic in terms of features — only single input file, so no stdin data, multiple files, etc.</p>
|
1182 |
| -<p>You'll need Python for this (I used 3.8, it should work for more recent versions too).</p> |
1183 |
| -<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#5597d6;">$</span><span> python3</span><span style="color:#5597d6;"> -m</span><span> venv textual_apps |
| 1182 | +<p>You'll need Python for this (I used 3.8, it should work for more recent versions too). This app is available on PyPI as <a href="https://pypi.org/project/cliexercises/">cliexercises</a>. Example installation instructions are shown below, adjust them based on your preferences and OS.</p> |
| 1183 | +<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#7f8989;"># virtual environment |
| 1184 | +</span><span style="color:#5597d6;">$</span><span> python3</span><span style="color:#5597d6;"> -m</span><span> venv textual_apps |
1184 | 1185 | </span><span style="color:#5597d6;">$</span><span> cd textual_apps
|
1185 | 1186 | </span><span style="color:#5597d6;">$</span><span> source bin/activate
|
1186 |
| -</span><span style="color:#5597d6;">$</span><span> pip install textual==0.5.0 |
| 1187 | +</span><span style="color:#5597d6;">$</span><span> pip install cliexercises |
1187 | 1188 | </span><span>
|
1188 |
| -</span><span style="color:#5597d6;">$</span><span> git clone</span><span style="color:#5597d6;"> --depth</span><span> 1 https://github.com/learnbyexample/TUI-apps.git |
1189 |
| -</span><span style="color:#5597d6;">$</span><span> cd TUI-apps/CLI-Exercises |
1190 |
| -</span><span style="color:#5597d6;">$</span><span> python cli_exercises.py |
| 1189 | +</span><span style="color:#7f8989;"># launch the app |
| 1190 | +</span><span style="color:#5597d6;">$</span><span> cliexercises |
| 1191 | +</span></code></pre> |
| 1192 | +<p>To run the app without having to enter the virtual environment again, add this alias to <code>.bashrc</code> (or equivalent):</p> |
| 1193 | +<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#7f8989;"># you&#39;ll have to change the path |
| 1194 | +</span><span style="color:#b39f04;">alias </span><span style="color:#c23f31;">cliexercises</span><span style="color:#72ab00;">=</span><span style="color:#d07711;">&#39;/path/to/textual_apps/bin/cliexercises&#39; |
1191 | 1195 | </span></code></pre>
|
| 1196 | +<p>As an alternative, you can install <code>textual</code> (see <a href="https://textual.textualize.io/getting_started/">Textual documentation</a> for more details), clone my <a href="https://github.com/learnbyexample/TUI-apps">TUI-apps repository</a> and run the <code>cli_exercises.py</code> file.</p> |
| 1197 | +<p>Adjust the terminal dimensions for the widgets to appear properly, for example 84x25 (characters x lines).</p> |
1192 | 1198 | <br>
|
1193 | 1199 | <h2 id="video-demo">Video demo<a class="zola-anchor" href="#video-demo" aria-label="Anchor link for: video-demo">🔗</a></h2>
|
1194 | 1200 | <p align="center"><iframe width="560" height="315" loading="lazy" src="https://www.youtube.com/embed/0ggfQzXeYJg" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
|
|
0 commit comments