|
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>2025-05-19T00:00:00+00:00</updated> |
| 8 | + <updated>2025-05-21T00:00:00+00:00</updated> |
9 | 9 | <id>https://learnbyexample.github.io/atom.xml</id>
|
| 10 | + <entry xml:lang="en"> |
| 11 | + <title>Better bindings for command line history search</title> |
| 12 | + <published>2025-05-21T00:00:00+00:00</published> |
| 13 | + <updated>2025-05-21T00:00:00+00:00</updated> |
| 14 | + <link rel="alternate" href="https://learnbyexample.github.io/mini/better-bindings-cli-history-search/" type="text/html"/> |
| 15 | + <id>https://learnbyexample.github.io/mini/better-bindings-cli-history-search/</id> |
| 16 | + <content type="html"><p>Do you find it confusing to use <code>Ctrl+r</code> for searching a command from shell history? I have the following mappings in the <code>~/.inputrc</code> file, so that I can use the <code>↑</code> and <code>↓</code> arrow keys instead.</p> |
| 17 | +<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#d07711;">&quot;\e[A&quot;</span><span style="color:#5597d6;">:</span><span> history-search-backward |
| 18 | +</span><span style="color:#d07711;">&quot;\e[B&quot;</span><span style="color:#5597d6;">:</span><span> history-search-forward |
| 19 | +</span></code></pre> |
| 20 | +<p>Normally, when you use the <code>↑</code> arrow key, you'll get the previous command from the history. You can repeatedly press the key to get more entries. With the above settings active, this behavior will change if you have some characters already typed before pressing the arrow key — you'll only get entries from the history that match these characters from the start of the command. If there are multiple matches, you can use the <code>↑</code> and <code>↓</code> keys repeatedly to move backwards and forwards through the list.</p> |
| 21 | +<p>If you want the matching to happen anywhere in command (same behavior as <code>Ctrl+r</code> and <code>Ctrl+s</code>), use the following lines instead:</p> |
| 22 | +<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#d07711;">&quot;\e[A&quot;</span><span style="color:#5597d6;">:</span><span> history-substring-search-backward |
| 23 | +</span><span style="color:#d07711;">&quot;\e[B&quot;</span><span style="color:#5597d6;">:</span><span> history-substring-search-forward |
| 24 | +</span></code></pre> |
| 25 | +<p>The <code>~/.inputrc</code> file affects any shell using the <code>readline</code> library (for example, programming language REPLs). You can use the <code>bind</code> command and put them in, <code>~/.bashrc</code> for example, to affect only that particular shell.</p> |
| 26 | +<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#b39f04;">bind </span><span style="color:#d07711;">&#39;&quot;\e[A&quot;: history-search-backward&#39; |
| 27 | +</span><span style="color:#b39f04;">bind </span><span style="color:#d07711;">&#39;&quot;\e[B&quot;: history-search-forward&#39; |
| 28 | +</span></code></pre> |
| 29 | +<blockquote> |
| 30 | +<p><img src="/images/info.svg" alt="info" /> See <a href="https://wiki.archlinux.org/title/Readline">wiki.archlinux: readline</a> for more details and examples.</p> |
| 31 | +</blockquote> |
| 32 | +</content> |
| 33 | + </entry> |
10 | 34 | <entry xml:lang="en">
|
11 | 35 | <title>Customizing pandoc to generate beautiful pdf and epub from markdown</title>
|
12 | 36 | <published>2025-05-19T00:00:00+00:00</published>
|
|
0 commit comments