learntmux.dev

Name, save and load buffers

Goal

buffer0 is renamed key and saved to ~/key.txt; ~/motd.txt is loaded as buffer motd.

Three commands, all typed at C-b :, all taking -b to say which buffer they act on:

setb -b old -n new
rename a buffer
saveb -b name path
write its contents to a file
loadb -b name path
read a file into a buffer with that name

Naming is the point: an automatic buffer is dropped once the pile passes 50, and a named one never is. ~ expands at the prompt, so ~/key.txt is /home/alpine/key.txt.

Do this

Press C-b :, type setb -b buffer0 -n key, Enter.

Only the name changed; the text is untouched.

Press C-b :, type saveb -b key ~/key.txt, Enter.

The buffer’s contents are now on disk.

Press C-b :, type loadb -b motd ~/motd.txt, Enter.

The file’s contents arrive as a new named buffer.

Press C-b =, then q.

The list shows key and motd, and no buffer0.

Creating a buffer directly

set-buffer -b name text creates a buffer outright, with no copying involved. Without -b, both set-buffer and load-buffer make a new automatic buffer instead.

Stuck on this one?

This is a live terminal. Typing goes to the machine, including Tab. Press Shift and Tab together to move focus back out to the page.

A real terminal, in this tab

about 15 MB, once

session learn

Done when

not started
  1. buffer0 has been renamed to key and still holds the copied text— not done yet
  2. The key buffer was saved to ~/key.txt— not done yet
  3. motd.txt was loaded into a buffer named motd— not done yet