Skip to content

Instantly share code, notes, and snippets.

@jandahl
Last active April 17, 2023 13:35
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jandahl/8436cd6a99d56efd9ff4 to your computer and use it in GitHub Desktop.
Save jandahl/8436cd6a99d56efd9ff4 to your computer and use it in GitHub Desktop.
Using GNU screen as a slow pasting virtual serial console terminal

Using GNU screen as a slow pasting virtual serial console terminal

A quick primer

You will need

  1. A Macintosh computer
  2. A USB-to-serial adapter
  3. A file with a config you want to paste sloooowly
  4. A few minutes

1. Make a sensible ~/.screenrc file

1.a. If you don't have a .screenrc already

Paste the following into a terminal - WARNING! Overwrites your .screenrc

cat <<EOF >> ~/.screenrc
startup_message off

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
 
defslowpaste 20 ## It is the value to the left that is the central one for your happiness
EOF

1.b. If you have a .screenrc file already

Add this:

slowpaste 20 ## It is the value to the left that is the central one for your happiness

2. Start a session to your serial converter

Your USB adapter ought to register as /dev/tty.SOMETHING, where SOMETHING is usually something with usb. You can try to find it by typing ls /dev/tty.*. In below example, I am using tty.usbserial-A504CTHN.

$ screen tty.usbserial-A504CTHN 9600

Appending 9600 signals to screen to use 9600 baud.

3. Open file to named buffer

Type Ctrl-A, then type :readreg p <file name> to save the contents of <file name> in a paste buffer named p. Any letter can be used, so you can have multiple paste buffers; e.g. d for default boilerplate, q for QoS, m for multicast, etc. The easiest way to ensure the correct file name in your terminal is simply to type Ctrl-A, :readreg p (including a trailing space), then dragging the file from the Finder to the terminal window.

4. Paste from your pastebuffer

Go where you want to paste (e.g. conf t mode), type Ctrl-A, then type :paste p. Magic ensues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment