Mosh and tmux - Remote Nivrana

Bri Hatch Personal Work
bri@ifokr.org Dropzone AI
daethnir@dropzone.ai

Copyright 2024, Bri Hatch, Creative Commons BY-NC-SA License

Problem Statement

I work from many devices

Problem Statement

I work from many devices

Problem Statement (cont)

I work from many places:

Problem Statement (cont)

What this means

My Solution

How I stay sane

Mosh

Mosh is

Mosh (cont)

Drawbacks

Welcome to MyOS (GNU/Linux 6.8.0-45-generic x86_64)

*** System restart required ***
  You have a detached Mosh session on this server ([1228285]).

tmux

TMUX - Terminal Multiplexer

VIM users necessity

Default prefix is <ctrl-b> which is frequently used in vim, less etc.

To use <ctrl-a> instead (screen compatible, sensible alternative)

$ cat ~/.tmux.conf

# Change the prefix key to C-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix

Status bar

$ grep ^[a-z] /usr/share/dict/words | shuf | tail -5
pistachios
esthetic
loiter
tomfoolery
conjecture
$
[0] 0:DNS- 1:pulumi*                     "pulumi" 04:43 19-Apr-22

Status bar (cont)

esthetic
loiter
tomfoolery
conjecture
$ tmux set -g status-left ""
$ tmux set -g status-right "%Y-%m-%d %H:%M|#(TZ=UTC date +%%H:%%M)"
$ 
0:DNS- 1:pulumi*                            2022-04-19 04:43|11:43

Easy to make aliases/programs that interact with tmux!

Example: Parallel Tasks











$ for host in $host_list ; do
    for container in $container_list ; do
      tmux new-window -n "$host $container" \
           ssh -ttt "$host" docker pull $container
    done
  done

0:deploy                                    2022-04-19 04:43|11:43

Example: Parallel Tasks (cont)

(0) - 0: 183 windows (attached)
(1) ├─> 0: deploy
(2) ├─> 1: prodweb-00 foo-nginx
(3) ├─> 1: prodweb-00 foo-web                            
(4) ├─> 1: prodweb-00 foo-db
(5) ├─> 1: prodweb-01 foo-nginx
(6) ├─> 1: prodweb-01 foo-web

┌────────────────────────────────────────────────────────┐
│83d624c4be2d: Already exists                            │
│1f62b39dc401: Pull complete                             │
│6c29a458e7d5: Pull complete                             │
│805908969407: Pull complete                             │
│2c1384c86539: Pull complete                             │
│b9a670e7a7f3: Pull complete                             │
│51635e63ab0c: Pull complete                             │
│57e3c615dedb: Extracting [==============>                                    ]  4.408MB/11.56MB                   │
0:deploy 1:prodweb-00 foo-nginx 2:prodweb-  2022-04-19 04:43|11:43

Starting / Connecting

Navagiting Windows

Panes

Live Demo!

Thanks!

Presentation: https://www.ifokr.org/bri/presentations/seagl-2024-mosh-and-tmux/

PersonalWork
Bri Hatch
bri@ifokr.org

Bri Hatch
Dropzone AI
daethnir@dropzone.ai

Copyright 2024, Bri Hatch, Creative Commons BY-NC-SA License