aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-05-17 20:46:55 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-05-17 20:46:55 +0200
commit4c3b21f0ba96fcce188f8c55599a4ec8a98a13fe (patch)
treeb746866fdf0c057a734b97f1f8591c8f249df82a /src
parentab3ca5e2bf3317933b7bec8d10f92cd4a5686991 (diff)
downloadsebastiano.tronto.net-4c3b21f0ba96fcce188f8c55599a4ec8a98a13fe.tar.gz
sebastiano.tronto.net-4c3b21f0ba96fcce188f8c55599a4ec8a98a13fe.zip
New blog post
Diffstat (limited to 'src')
-rw-r--r--src/blog/2024-07-11-tmux-battery/tmux-battery.md6
-rw-r--r--src/blog/2026-05-17-tmux-clipboard/tmux-clipboard.md56
-rw-r--r--src/series/series.md14
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
4you to create multiple virtual terminals in the same shell and keep 6you 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
162understanding of this is still superficial, but for now I am happy 164understanding of this is still superficial, but for now I am happy
163that the battery status is there. Maybe I'll learn about sessions 165that the battery status is there. Maybe I'll learn about sessions
164at some point, and I'll write a new blog post about them :) 166at 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
5Recently, for reasons that I may explain in a future blog post, I went
6through some old configuration files of mine, and I found something in
7my `.tmux.conf` that I thought would be worth a second post in this
8series - 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*
13that allows one to visually select and copy text, all via your keyboard.
14By default you can enter copy mode by pressing `C-b [` (`Ctrl+B` followed
15by `[`); from there you can navigate the text that is currently on your
16terminal with arrow keys and [Emacs](https://en.wikipedia.org/wiki/Emacs)-style
17key bindings - or with hjkl and other
18[Vim](https://en.wikipedia.org/wiki/Vim_(text_editor))-style bindings if
19you have a `VISUAL` or `EDITOR` [environment
20variable](https://en.wikipedia.org/wiki/Environment_variable) set to `vi`.
21
22You can then start selecting text by pressing `Space`, and confirm the
23selection by pressing `Enter`. The selection will then be copied to
24an internal tmux buffer, and you can paste it by pressing `C-b ]`.
25
26Actually, tmux offers multiple copy-buffers, but honestly I have never
27used this feature. You can read more about this in its [manual
28page](https://man.openbsd.org/tmux).
29
30## Copy to clipboard
31
32By default, tmux will copy the selection to its internal buffer, but you
33may want to paste that text somewhere outside of tmux - maybe in a chat
34application or in a web browser URL bar. And here is the trick: you can
35actually tell tmux to [pipe](https://en.wikipedia.org/wiki/Pipeline_(Unix))
36the selection to a custom command. For example, if you have this in your
37`.tmux.conf`:
38
39```
40set -s copy-command "xsel -ib"
41```
42
43tmux will not only copy the selection to its internal buffer, but also
44send it to the `xsel -ib` command. In case you did not know,
45[`xsel`](https://linux.die.net/man/1/xsel)
46is a command that copies its standard input to the X session
47[clipboard](https://en.wikipedia.org/wiki/Clipboard_(computing));
48this way you will be able to paste the copied text into any other
49graphical application with the usual `Ctrl+V`. Neat!
50
51## tmux show-buffer
52
53Here one last trick: with the `tmux show-buffer` command you can print the
54current tmux selection to standard output. You can use this in shell scripts,
55for example, or in more complex tmux key bindings in your configuration file.
56And 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
56I have recently started learning Rust, documenting the process in a 56Some tips and tricks for using [tmux](https://en.wikipedia.org/wiki/Tmux),
57small series of blog posts. These posts are all marked by the crab emoji 57the 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 58aspect of this application at the time, without going too in depth into
59I understand. 59the 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)

Generated with cgit - Back to sebastiano.tronto.net