diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-17 20:46:55 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-05-17 20:46:55 +0200 |
| commit | 4c3b21f0ba96fcce188f8c55599a4ec8a98a13fe (patch) | |
| tree | b746866fdf0c057a734b97f1f8591c8f249df82a | |
| parent | ab3ca5e2bf3317933b7bec8d10f92cd4a5686991 (diff) | |
| download | sebastiano.tronto.net-4c3b21f0ba96fcce188f8c55599a4ec8a98a13fe.tar.gz sebastiano.tronto.net-4c3b21f0ba96fcce188f8c55599a4ec8a98a13fe.zip | |
New blog post
| -rw-r--r-- | src/blog/2024-07-11-tmux-battery/tmux-battery.md | 6 | ||||
| -rw-r--r-- | src/blog/2026-05-17-tmux-clipboard/tmux-clipboard.md | 56 | ||||
| -rw-r--r-- | src/series/series.md | 14 |
3 files changed, 68 insertions, 8 deletions
diff --git a/src/blog/2024-07-11-tmux-battery/tmux-battery.md b/src/blog/2024-07-11-tmux-battery/tmux-battery.md index 1ea5b99..c9a1f0b 100644 --- a/src/blog/2024-07-11-tmux-battery/tmux-battery.md +++ b/src/blog/2024-07-11-tmux-battery/tmux-battery.md | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | # tmux tricks #1: battery status indicator | 1 | # tmux trick #1: battery status indicator |
| 2 | |||
| 3 | *This post is part of a [series](../../series)* | ||
| 2 | 4 | ||
| 3 | [tmux](https://github.com/tmux/tmux/wiki) is a program that allows | 5 | [tmux](https://github.com/tmux/tmux/wiki) is a program that allows |
| 4 | you to create multiple virtual terminals in the same shell and keep | 6 | you to create multiple virtual terminals in the same shell and keep |
| @@ -162,3 +164,5 @@ is created. The `-g` is used to apply this command globally. My | |||
| 162 | understanding of this is still superficial, but for now I am happy | 164 | understanding of this is still superficial, but for now I am happy |
| 163 | that the battery status is there. Maybe I'll learn about sessions | 165 | that the battery status is there. Maybe I'll learn about sessions |
| 164 | at some point, and I'll write a new blog post about them :) | 166 | at some point, and I'll write a new blog post about them :) |
| 167 | |||
| 168 | *Next in the series: [copy to clipboard](../2026-05-17-tmux-clipboard)* | ||
diff --git a/src/blog/2026-05-17-tmux-clipboard/tmux-clipboard.md b/src/blog/2026-05-17-tmux-clipboard/tmux-clipboard.md new file mode 100644 index 0000000..f1721fe --- /dev/null +++ b/src/blog/2026-05-17-tmux-clipboard/tmux-clipboard.md | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | # tmux trick #2: copy to clipboard | ||
| 2 | |||
| 3 | *This post is part of a [series](../../series)* | ||
| 4 | |||
| 5 | Recently, for reasons that I may explain in a future blog post, I went | ||
| 6 | through some old configuration files of mine, and I found something in | ||
| 7 | my `.tmux.conf` that I thought would be worth a second post in this | ||
| 8 | series - only 2 years after the first episode, not bad! | ||
| 9 | |||
| 10 | ## Copy mode | ||
| 11 | |||
| 12 | [tmux](https://en.wikipedia.org/wiki/Tmux) has a feature called *copy mode* | ||
| 13 | that allows one to visually select and copy text, all via your keyboard. | ||
| 14 | By default you can enter copy mode by pressing `C-b [` (`Ctrl+B` followed | ||
| 15 | by `[`); from there you can navigate the text that is currently on your | ||
| 16 | terminal with arrow keys and [Emacs](https://en.wikipedia.org/wiki/Emacs)-style | ||
| 17 | key bindings - or with hjkl and other | ||
| 18 | [Vim](https://en.wikipedia.org/wiki/Vim_(text_editor))-style bindings if | ||
| 19 | you have a `VISUAL` or `EDITOR` [environment | ||
| 20 | variable](https://en.wikipedia.org/wiki/Environment_variable) set to `vi`. | ||
| 21 | |||
| 22 | You can then start selecting text by pressing `Space`, and confirm the | ||
| 23 | selection by pressing `Enter`. The selection will then be copied to | ||
| 24 | an internal tmux buffer, and you can paste it by pressing `C-b ]`. | ||
| 25 | |||
| 26 | Actually, tmux offers multiple copy-buffers, but honestly I have never | ||
| 27 | used this feature. You can read more about this in its [manual | ||
| 28 | page](https://man.openbsd.org/tmux). | ||
| 29 | |||
| 30 | ## Copy to clipboard | ||
| 31 | |||
| 32 | By default, tmux will copy the selection to its internal buffer, but you | ||
| 33 | may want to paste that text somewhere outside of tmux - maybe in a chat | ||
| 34 | application or in a web browser URL bar. And here is the trick: you can | ||
| 35 | actually tell tmux to [pipe](https://en.wikipedia.org/wiki/Pipeline_(Unix)) | ||
| 36 | the selection to a custom command. For example, if you have this in your | ||
| 37 | `.tmux.conf`: | ||
| 38 | |||
| 39 | ``` | ||
| 40 | set -s copy-command "xsel -ib" | ||
| 41 | ``` | ||
| 42 | |||
| 43 | tmux will not only copy the selection to its internal buffer, but also | ||
| 44 | send it to the `xsel -ib` command. In case you did not know, | ||
| 45 | [`xsel`](https://linux.die.net/man/1/xsel) | ||
| 46 | is a command that copies its standard input to the X session | ||
| 47 | [clipboard](https://en.wikipedia.org/wiki/Clipboard_(computing)); | ||
| 48 | this way you will be able to paste the copied text into any other | ||
| 49 | graphical application with the usual `Ctrl+V`. Neat! | ||
| 50 | |||
| 51 | ## tmux show-buffer | ||
| 52 | |||
| 53 | Here one last trick: with the `tmux show-buffer` command you can print the | ||
| 54 | current tmux selection to standard output. You can use this in shell scripts, | ||
| 55 | for example, or in more complex tmux key bindings in your configuration file. | ||
| 56 | And that's a teaser for the next tmux trick :) | ||
diff --git a/src/series/series.md b/src/series/series.md index a98b85c..2194d90 100644 --- a/src/series/series.md +++ b/src/series/series.md | |||
| @@ -51,12 +51,12 @@ My adventures in learning C++ as a C programmer. | |||
| 51 | * Episode 2: [RAII](../blog/2024-12-26-taming-cpp-raii) | 51 | * Episode 2: [RAII](../blog/2024-12-26-taming-cpp-raii) |
| 52 | * Episode 3: [templates, constraints and concepts](../blog/2025-01-21-taming-cpp-templates) | 52 | * Episode 3: [templates, constraints and concepts](../blog/2025-01-21-taming-cpp-templates) |
| 53 | 53 | ||
| 54 | ## Learning Rust | 54 | ## tmux tricks |
| 55 | 55 | ||
| 56 | I have recently started learning Rust, documenting the process in a | 56 | Some tips and tricks for using [tmux](https://en.wikipedia.org/wiki/Tmux), |
| 57 | small series of blog posts. These posts are all marked by the crab emoji | 57 | the terminal multiplexer. In these posts I try to focus on one practical |
| 58 | '🦀', which is something of a meme in the Rust community, as far as | 58 | aspect of this application at the time, without going too in depth into |
| 59 | I understand. | 59 | the inner workings of tmux. |
| 60 | 60 | ||
| 61 | * [Cargo culture shock](../blog/2025-06-13-cargo-culture-shock) | 61 | * Trick #1: [battery status indicator](../blog/2024-07-11-tmux-battery) |
| 62 | * [Stunned by the borrow checker](../blog/2025-06-26-borrow-checker) | 62 | * Trick #2: [copy to clipboard](../blog/2026-05-17-tmux-clipboard) |
