-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulti-user.Rmd
150 lines (106 loc) · 4.86 KB
/
multi-user.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---
author: Dirk Eddelbuettel, Vincent Arel-Bundock, Grant McDermott
title: Multi-user Concurrent Editing with Emacs
subtitle: "Part of the ESS-Intro (and t4) series"
institute: "`r format(Sys.Date(), 'This version is dated %d %b %Y')`"
output:
binb::metropolis:
incremental: false
fontsize: 12pt
classoption: compress,aspectratio=169,handout
classoptionFull: compress,aspectratio=169
header-includes:
- |
```{=latex}
\metroset{titleformat=smallcaps,numbering=fraction,background=light}
\setbeamercolor{frametitle}{bg=orange}
\hypersetup{colorlinks,citecolor=orange,filecolor=orange,linkcolor=orange,urlcolor=orange}
\titlegraphic{\includegraphics[width=2cm]{images/logoESS.png}}
```
---
## Emacs: Multi-User Concurrent Editing
### Motivation
- A lot of love online for how _editor XYZ_ supports multi-user mode
- But ... we have been able to do that with standard Unix tools for two+ decades
- As in Dirk's [_t4_ series](http://dirk.eddelbuettel.com/blog/code/t4/) it
is about _combining_ existing (shell) tools for better use
- Here: `tmux`, or its alternate frontend `byobu`, can shine
## Emacs: Multi-User Concurrent Editing
### Setup
- Requirement: We assume multiple accounts on the same machine
- _e.g._ a departmental server, research group server, AWS/GCS/Azure/DO instance ...
- Each participant needs to
- be able to access the box via `ssh`
- have access to a shared (_i.e._ "joint") "named" tmux socket
- (and we do not cover account creation, `root` use, ...)
- We then merely invoke `tmux` (or `byobu`), once creating a named socket
- *Everything* running inside the tmux/byobu session can then be shared
- Including Emacs (in terminal mode) or anything else working in terminal
mode
## Emacs: Multi-User Concurrent Editing
### Simplest Demo: Launch It
This runs starts the session, _i.e._ the one granting access to his session.
```sh
# start tmux: named socket (-S), group (-t) and session (-s) names
$ tmux -S /tmp/joint-session new-session -t joint -s joint
# we are now in a tmux session
> chmod o+rw /tmp/joint-session # so that other user can access
```
\medskip
We created a _new session_ under the handle 'joint' and gave it `rw` (==
"read-write") rights. (In real settings you probably want both users under a
common 'group' for the joint project and make the socket group rw.)
## Emacs: Multi-User Concurrent Editing
### Simplest Demo: Joint It
This runs as one of the users accessing the session. The only requirements
are to be one the same machine, _and_ to be part of the group having access
to the shared socket.
```sh
$ tmux -S /tmp/joint-session attach-session -t joint ## or also
$ byobu -S /tmp/joint-session attach-session -t joint
```
That. Is. All. The two sessions mirror each other.
So do `emacs -nw` or `R` or ... whatever command session you want to share.
Best of all: _All_ the `byobu` (or `tmux`) goodness we talked about in t4
works the same way. Multiple concurrent sessions. Persistent sessions _i.e._
start this, leave it running, re-connect tomorrow. Or next month.
<!-- ## Emacs: Multi-User -->
<!-- ### Alternate Demo (as user `edd`) -->
<!-- - If you prefer `byobu` (as I do) and have it use `tmux` (instead of -->
<!-- `screen`) -->
<!-- - Just do `byobu -S /tmp/scratch/session new-session -t joint` -->
<!-- - Followed by `chmod o+rw ....` or `chgrp` or ... -->
## Emacs: Multi-User Concurrent Editing
### Other Tricks
- Start `emacs --daemon` to have emacs sessions persist
- Log on and off, attach and detach `byobu` / `tmux` and resume
- Emacs sessions remain accessible
- Plotting on tty is an issue but _e.g._ `httpgd` may help
- but ideally we would be able to have it send traffic to mulitple devices
/ users
## Emacs: Multi-User Concurrent Editing
### Lastly ...
- This is not meant to be normative
- Other editors can do similar things just fine (`code` is popular)
- (Commercial) online solutions also available (\url{replit.io})
### But ... we really like Emacs as it
- is 'always there'
- has support for just about anything
- is extensible
## Emacs: Multi-User Concurrent Editing
### Security
- We do stress that letting other users access
- _your_ session via the shared socket
- gives them _your session_ with access to all _you_ can access
- this may include mail, gpg or ssh keys and more
- That means _any_ files accessible to _you_ are now also accessible to them
- So use on personal servers containing personal data may not be the first choice
- However, on work or cloud settings with no personal files less of an issue
## Emacs: Multi-User Concurrent Editing
### Summary
- An _easy_ and _powerful_ and _generic_ way to share a session
- Works for Emacs, also works for other (console) editors, R, ...
- While keeping possible limitation in mind, it can facilitate collaboration
<!-- # Appendix -->
<!-- ## Open Questions -->
<!-- - Detach (normal) versus exit (once ?) -->