cf-share-tmux 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gabrys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: cf-share-tmux
3
+ Version: 0.1.0
4
+ Summary: Share a tmux window in the browser with ttyd, optionally through a Cloudflare quick tunnel.
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/gabrys/cf-share-tmux
7
+ Project-URL: Issues, https://github.com/gabrys/cf-share-tmux/issues
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Topic :: Terminals
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # cf-share-tmux
21
+
22
+ Share one tmux window in the browser with [ttyd](https://github.com/tsl0922/ttyd),
23
+ locally or publicly through a Cloudflare quick tunnel.
24
+
25
+ ```sh
26
+ cf-share-tmux work:2 --cf-tunnel -c 'alice:long-random-password'
27
+ ```
28
+
29
+ prints the local and the public `https://….trycloudflare.com` URL and the PID,
30
+ then returns to the shell while sharing continues in the background. Stop it
31
+ with `kill <PID>`; it also stops by itself when you close the shared window.
32
+
33
+ ## Requirements
34
+
35
+ Linux, Python 3.10 or newer (standard library only) and these executables on
36
+ your `PATH`:
37
+
38
+ - `tmux`
39
+ - [`ttyd`](https://github.com/tsl0922/ttyd)
40
+ - [`cloudflared`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/),
41
+ only for `--cf-tunnel`
42
+
43
+ Installing this package does not install any of them.
44
+
45
+ ## Installation
46
+
47
+ ```sh
48
+ uv tool install cf-share-tmux
49
+ ```
50
+
51
+ Requires [uv](https://docs.astral.sh/uv/getting-started/installation/).
52
+ `uvx cf-share-tmux --help` runs it without installing. You can also run the
53
+ single file directly: `python3 cf_share_tmux.py --help`.
54
+
55
+ ## Usage
56
+
57
+ ```sh
58
+ cf-share-tmux TARGET [options]
59
+ ```
60
+
61
+ `TARGET` is a tmux window, for example `work:2` or `work:editor`.
62
+
63
+ | Option | Default | Meaning |
64
+ |---|---|---|
65
+ | `-p`, `--port` | `7681` | Local HTTP port for ttyd |
66
+ | `-b`, `--bind` | `127.0.0.1` | Address ttyd listens on |
67
+ | `-c`, `--credential USER:PASSWORD` | none | HTTP Basic Auth; also read from `TTYD_CREDENTIAL` |
68
+ | `--read-only` | off | Viewers cannot type |
69
+ | `--check-origin` | off | Make ttyd reject WebSocket connections from other origins |
70
+ | `--cf-tunnel` | off | Also publish through a Cloudflare quick tunnel; needs `-c` |
71
+ | `--json` | off | Print only `{"url": "<public URL>", "pid": <PID>}` on stdout; needs `--cf-tunnel` |
72
+ | `--foreground` | off | Stay in the foreground until Ctrl+C instead of going to the background |
73
+ | `--version` | | Print the version |
74
+
75
+ Without `--json`, stdout shows the window, the temporary session, the local
76
+ URL, whether auth is enabled, the PID and, with `--cf-tunnel`,
77
+ `Public: <URL>`. With `--json`, stdout gets that single JSON line and nothing
78
+ else; errors still go to stderr.
79
+
80
+ The command returns as soon as the share is ready: with `--cf-tunnel` when the
81
+ public URL is known, without it once ttyd has been running for a second. Its
82
+ exit status is 0 then, or the error status if something failed before that, so
83
+ scripts can simply do:
84
+
85
+ ```sh
86
+ url=$(cf-share-tmux work:2 --cf-tunnel --json --read-only -c "$CRED" | jq -r .url)
87
+ ```
88
+
89
+ ## How it works
90
+
91
+ 1. The target is resolved to a stable window ID.
92
+ 2. Unless `--foreground` is given, the process forks: the child detaches from
93
+ the terminal and does the work, the parent waits until the child reports
94
+ that it is ready and then exits.
95
+ 3. A temporary session `serve-tmux-<port>-<random>` is created and the window
96
+ is linked into it, so the browser starts on that window only.
97
+ 4. ttyd serves `tmux attach-session` to that session.
98
+ 5. With `--cf-tunnel`, cloudflared publishes ttyd. Its log is hidden; the
99
+ public URL is taken from it. If cloudflared exits without a URL, the last
100
+ 20 lines of its log go to stderr.
101
+ 6. Once in the background, the process no longer writes anywhere; later errors
102
+ are not shown.
103
+ 7. It stops on SIGTERM (`kill <PID>`), on Ctrl+C or SIGHUP in the foreground,
104
+ when ttyd or cloudflared exits, or when the shared window is closed. Then
105
+ ttyd and cloudflared are stopped and the temporary session is removed. The
106
+ window itself stays in its original session.
107
+ 8. ttyd and cloudflared are started with the Linux parent-death signal, so they
108
+ are terminated even if the process is killed with `kill -9`; only the
109
+ temporary tmux session is left behind in that case.
110
+
111
+ ## Security
112
+
113
+ Read this before sharing anything.
114
+
115
+ - **Input is enabled by default.** Anyone who can open the page can type into
116
+ your shell, with your user's permissions. Use `--read-only` unless you mean
117
+ to hand over a shell.
118
+ - **The temporary session is not a sandbox.** With input enabled, a viewer can
119
+ use tmux key bindings to switch to any of your other sessions and windows.
120
+ - **Use `--check-origin`.** Without it, any web page open in your browser can
121
+ connect to the local ttyd WebSocket; browsers also send saved Basic Auth
122
+ credentials with such connections.
123
+ - **The password is visible to local users.** It is passed to ttyd on the
124
+ command line, so `ps` shows it, even when it comes from `TTYD_CREDENTIAL`.
125
+ - **Through the tunnel, the password is the only protection.** Anyone who
126
+ learns the URL can try to guess it; use a long random one.
127
+ - Without `--cf-tunnel`, `-b 0.0.0.0` without `-c` exposes your shell to the
128
+ whole local network over plain HTTP.
129
+
130
+ ## Development
131
+
132
+ ```sh
133
+ uv run python -m unittest discover -s tests -v
134
+ uvx --from build pyproject-build
135
+ uvx twine check --strict dist/*
136
+ ```
137
+
138
+ The tests need `tmux` for the end-to-end part (skipped otherwise). They run
139
+ their own tmux server and fake `ttyd` and `cloudflared`, so they do not touch
140
+ your sessions or the network.
141
+
142
+ ## Publishing
143
+
144
+ The version lives in `__version__` in `cf_share_tmux.py` (currently `0.1.0`).
145
+ Build from a clean checkout using the commands above, ensuring `dist/` contains
146
+ only the current release, then upload:
147
+
148
+ ```sh
149
+ uvx twine upload dist/*
150
+ ```
151
+
152
+ Use an API token when Twine prompts for credentials. Never commit credentials.
153
+ For subsequent releases, bump `__version__` and build fresh artifacts; PyPI does
154
+ not allow replacing an existing release file. GitHub Actions runs tests and
155
+ validates distributions; publishing is manual.
156
+
157
+ ## License
158
+
159
+ MIT; see [LICENSE](LICENSE).
@@ -0,0 +1,140 @@
1
+ # cf-share-tmux
2
+
3
+ Share one tmux window in the browser with [ttyd](https://github.com/tsl0922/ttyd),
4
+ locally or publicly through a Cloudflare quick tunnel.
5
+
6
+ ```sh
7
+ cf-share-tmux work:2 --cf-tunnel -c 'alice:long-random-password'
8
+ ```
9
+
10
+ prints the local and the public `https://….trycloudflare.com` URL and the PID,
11
+ then returns to the shell while sharing continues in the background. Stop it
12
+ with `kill <PID>`; it also stops by itself when you close the shared window.
13
+
14
+ ## Requirements
15
+
16
+ Linux, Python 3.10 or newer (standard library only) and these executables on
17
+ your `PATH`:
18
+
19
+ - `tmux`
20
+ - [`ttyd`](https://github.com/tsl0922/ttyd)
21
+ - [`cloudflared`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/),
22
+ only for `--cf-tunnel`
23
+
24
+ Installing this package does not install any of them.
25
+
26
+ ## Installation
27
+
28
+ ```sh
29
+ uv tool install cf-share-tmux
30
+ ```
31
+
32
+ Requires [uv](https://docs.astral.sh/uv/getting-started/installation/).
33
+ `uvx cf-share-tmux --help` runs it without installing. You can also run the
34
+ single file directly: `python3 cf_share_tmux.py --help`.
35
+
36
+ ## Usage
37
+
38
+ ```sh
39
+ cf-share-tmux TARGET [options]
40
+ ```
41
+
42
+ `TARGET` is a tmux window, for example `work:2` or `work:editor`.
43
+
44
+ | Option | Default | Meaning |
45
+ |---|---|---|
46
+ | `-p`, `--port` | `7681` | Local HTTP port for ttyd |
47
+ | `-b`, `--bind` | `127.0.0.1` | Address ttyd listens on |
48
+ | `-c`, `--credential USER:PASSWORD` | none | HTTP Basic Auth; also read from `TTYD_CREDENTIAL` |
49
+ | `--read-only` | off | Viewers cannot type |
50
+ | `--check-origin` | off | Make ttyd reject WebSocket connections from other origins |
51
+ | `--cf-tunnel` | off | Also publish through a Cloudflare quick tunnel; needs `-c` |
52
+ | `--json` | off | Print only `{"url": "<public URL>", "pid": <PID>}` on stdout; needs `--cf-tunnel` |
53
+ | `--foreground` | off | Stay in the foreground until Ctrl+C instead of going to the background |
54
+ | `--version` | | Print the version |
55
+
56
+ Without `--json`, stdout shows the window, the temporary session, the local
57
+ URL, whether auth is enabled, the PID and, with `--cf-tunnel`,
58
+ `Public: <URL>`. With `--json`, stdout gets that single JSON line and nothing
59
+ else; errors still go to stderr.
60
+
61
+ The command returns as soon as the share is ready: with `--cf-tunnel` when the
62
+ public URL is known, without it once ttyd has been running for a second. Its
63
+ exit status is 0 then, or the error status if something failed before that, so
64
+ scripts can simply do:
65
+
66
+ ```sh
67
+ url=$(cf-share-tmux work:2 --cf-tunnel --json --read-only -c "$CRED" | jq -r .url)
68
+ ```
69
+
70
+ ## How it works
71
+
72
+ 1. The target is resolved to a stable window ID.
73
+ 2. Unless `--foreground` is given, the process forks: the child detaches from
74
+ the terminal and does the work, the parent waits until the child reports
75
+ that it is ready and then exits.
76
+ 3. A temporary session `serve-tmux-<port>-<random>` is created and the window
77
+ is linked into it, so the browser starts on that window only.
78
+ 4. ttyd serves `tmux attach-session` to that session.
79
+ 5. With `--cf-tunnel`, cloudflared publishes ttyd. Its log is hidden; the
80
+ public URL is taken from it. If cloudflared exits without a URL, the last
81
+ 20 lines of its log go to stderr.
82
+ 6. Once in the background, the process no longer writes anywhere; later errors
83
+ are not shown.
84
+ 7. It stops on SIGTERM (`kill <PID>`), on Ctrl+C or SIGHUP in the foreground,
85
+ when ttyd or cloudflared exits, or when the shared window is closed. Then
86
+ ttyd and cloudflared are stopped and the temporary session is removed. The
87
+ window itself stays in its original session.
88
+ 8. ttyd and cloudflared are started with the Linux parent-death signal, so they
89
+ are terminated even if the process is killed with `kill -9`; only the
90
+ temporary tmux session is left behind in that case.
91
+
92
+ ## Security
93
+
94
+ Read this before sharing anything.
95
+
96
+ - **Input is enabled by default.** Anyone who can open the page can type into
97
+ your shell, with your user's permissions. Use `--read-only` unless you mean
98
+ to hand over a shell.
99
+ - **The temporary session is not a sandbox.** With input enabled, a viewer can
100
+ use tmux key bindings to switch to any of your other sessions and windows.
101
+ - **Use `--check-origin`.** Without it, any web page open in your browser can
102
+ connect to the local ttyd WebSocket; browsers also send saved Basic Auth
103
+ credentials with such connections.
104
+ - **The password is visible to local users.** It is passed to ttyd on the
105
+ command line, so `ps` shows it, even when it comes from `TTYD_CREDENTIAL`.
106
+ - **Through the tunnel, the password is the only protection.** Anyone who
107
+ learns the URL can try to guess it; use a long random one.
108
+ - Without `--cf-tunnel`, `-b 0.0.0.0` without `-c` exposes your shell to the
109
+ whole local network over plain HTTP.
110
+
111
+ ## Development
112
+
113
+ ```sh
114
+ uv run python -m unittest discover -s tests -v
115
+ uvx --from build pyproject-build
116
+ uvx twine check --strict dist/*
117
+ ```
118
+
119
+ The tests need `tmux` for the end-to-end part (skipped otherwise). They run
120
+ their own tmux server and fake `ttyd` and `cloudflared`, so they do not touch
121
+ your sessions or the network.
122
+
123
+ ## Publishing
124
+
125
+ The version lives in `__version__` in `cf_share_tmux.py` (currently `0.1.0`).
126
+ Build from a clean checkout using the commands above, ensuring `dist/` contains
127
+ only the current release, then upload:
128
+
129
+ ```sh
130
+ uvx twine upload dist/*
131
+ ```
132
+
133
+ Use an API token when Twine prompts for credentials. Never commit credentials.
134
+ For subsequent releases, bump `__version__` and build fresh artifacts; PyPI does
135
+ not allow replacing an existing release file. GitHub Actions runs tests and
136
+ validates distributions; publishing is manual.
137
+
138
+ ## License
139
+
140
+ MIT; see [LICENSE](LICENSE).
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: cf-share-tmux
3
+ Version: 0.1.0
4
+ Summary: Share a tmux window in the browser with ttyd, optionally through a Cloudflare quick tunnel.
5
+ License-Expression: MIT
6
+ Project-URL: Repository, https://github.com/gabrys/cf-share-tmux
7
+ Project-URL: Issues, https://github.com/gabrys/cf-share-tmux/issues
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Topic :: Terminals
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # cf-share-tmux
21
+
22
+ Share one tmux window in the browser with [ttyd](https://github.com/tsl0922/ttyd),
23
+ locally or publicly through a Cloudflare quick tunnel.
24
+
25
+ ```sh
26
+ cf-share-tmux work:2 --cf-tunnel -c 'alice:long-random-password'
27
+ ```
28
+
29
+ prints the local and the public `https://….trycloudflare.com` URL and the PID,
30
+ then returns to the shell while sharing continues in the background. Stop it
31
+ with `kill <PID>`; it also stops by itself when you close the shared window.
32
+
33
+ ## Requirements
34
+
35
+ Linux, Python 3.10 or newer (standard library only) and these executables on
36
+ your `PATH`:
37
+
38
+ - `tmux`
39
+ - [`ttyd`](https://github.com/tsl0922/ttyd)
40
+ - [`cloudflared`](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/),
41
+ only for `--cf-tunnel`
42
+
43
+ Installing this package does not install any of them.
44
+
45
+ ## Installation
46
+
47
+ ```sh
48
+ uv tool install cf-share-tmux
49
+ ```
50
+
51
+ Requires [uv](https://docs.astral.sh/uv/getting-started/installation/).
52
+ `uvx cf-share-tmux --help` runs it without installing. You can also run the
53
+ single file directly: `python3 cf_share_tmux.py --help`.
54
+
55
+ ## Usage
56
+
57
+ ```sh
58
+ cf-share-tmux TARGET [options]
59
+ ```
60
+
61
+ `TARGET` is a tmux window, for example `work:2` or `work:editor`.
62
+
63
+ | Option | Default | Meaning |
64
+ |---|---|---|
65
+ | `-p`, `--port` | `7681` | Local HTTP port for ttyd |
66
+ | `-b`, `--bind` | `127.0.0.1` | Address ttyd listens on |
67
+ | `-c`, `--credential USER:PASSWORD` | none | HTTP Basic Auth; also read from `TTYD_CREDENTIAL` |
68
+ | `--read-only` | off | Viewers cannot type |
69
+ | `--check-origin` | off | Make ttyd reject WebSocket connections from other origins |
70
+ | `--cf-tunnel` | off | Also publish through a Cloudflare quick tunnel; needs `-c` |
71
+ | `--json` | off | Print only `{"url": "<public URL>", "pid": <PID>}` on stdout; needs `--cf-tunnel` |
72
+ | `--foreground` | off | Stay in the foreground until Ctrl+C instead of going to the background |
73
+ | `--version` | | Print the version |
74
+
75
+ Without `--json`, stdout shows the window, the temporary session, the local
76
+ URL, whether auth is enabled, the PID and, with `--cf-tunnel`,
77
+ `Public: <URL>`. With `--json`, stdout gets that single JSON line and nothing
78
+ else; errors still go to stderr.
79
+
80
+ The command returns as soon as the share is ready: with `--cf-tunnel` when the
81
+ public URL is known, without it once ttyd has been running for a second. Its
82
+ exit status is 0 then, or the error status if something failed before that, so
83
+ scripts can simply do:
84
+
85
+ ```sh
86
+ url=$(cf-share-tmux work:2 --cf-tunnel --json --read-only -c "$CRED" | jq -r .url)
87
+ ```
88
+
89
+ ## How it works
90
+
91
+ 1. The target is resolved to a stable window ID.
92
+ 2. Unless `--foreground` is given, the process forks: the child detaches from
93
+ the terminal and does the work, the parent waits until the child reports
94
+ that it is ready and then exits.
95
+ 3. A temporary session `serve-tmux-<port>-<random>` is created and the window
96
+ is linked into it, so the browser starts on that window only.
97
+ 4. ttyd serves `tmux attach-session` to that session.
98
+ 5. With `--cf-tunnel`, cloudflared publishes ttyd. Its log is hidden; the
99
+ public URL is taken from it. If cloudflared exits without a URL, the last
100
+ 20 lines of its log go to stderr.
101
+ 6. Once in the background, the process no longer writes anywhere; later errors
102
+ are not shown.
103
+ 7. It stops on SIGTERM (`kill <PID>`), on Ctrl+C or SIGHUP in the foreground,
104
+ when ttyd or cloudflared exits, or when the shared window is closed. Then
105
+ ttyd and cloudflared are stopped and the temporary session is removed. The
106
+ window itself stays in its original session.
107
+ 8. ttyd and cloudflared are started with the Linux parent-death signal, so they
108
+ are terminated even if the process is killed with `kill -9`; only the
109
+ temporary tmux session is left behind in that case.
110
+
111
+ ## Security
112
+
113
+ Read this before sharing anything.
114
+
115
+ - **Input is enabled by default.** Anyone who can open the page can type into
116
+ your shell, with your user's permissions. Use `--read-only` unless you mean
117
+ to hand over a shell.
118
+ - **The temporary session is not a sandbox.** With input enabled, a viewer can
119
+ use tmux key bindings to switch to any of your other sessions and windows.
120
+ - **Use `--check-origin`.** Without it, any web page open in your browser can
121
+ connect to the local ttyd WebSocket; browsers also send saved Basic Auth
122
+ credentials with such connections.
123
+ - **The password is visible to local users.** It is passed to ttyd on the
124
+ command line, so `ps` shows it, even when it comes from `TTYD_CREDENTIAL`.
125
+ - **Through the tunnel, the password is the only protection.** Anyone who
126
+ learns the URL can try to guess it; use a long random one.
127
+ - Without `--cf-tunnel`, `-b 0.0.0.0` without `-c` exposes your shell to the
128
+ whole local network over plain HTTP.
129
+
130
+ ## Development
131
+
132
+ ```sh
133
+ uv run python -m unittest discover -s tests -v
134
+ uvx --from build pyproject-build
135
+ uvx twine check --strict dist/*
136
+ ```
137
+
138
+ The tests need `tmux` for the end-to-end part (skipped otherwise). They run
139
+ their own tmux server and fake `ttyd` and `cloudflared`, so they do not touch
140
+ your sessions or the network.
141
+
142
+ ## Publishing
143
+
144
+ The version lives in `__version__` in `cf_share_tmux.py` (currently `0.1.0`).
145
+ Build from a clean checkout using the commands above, ensuring `dist/` contains
146
+ only the current release, then upload:
147
+
148
+ ```sh
149
+ uvx twine upload dist/*
150
+ ```
151
+
152
+ Use an API token when Twine prompts for credentials. Never commit credentials.
153
+ For subsequent releases, bump `__version__` and build fresh artifacts; PyPI does
154
+ not allow replacing an existing release file. GitHub Actions runs tests and
155
+ validates distributions; publishing is manual.
156
+
157
+ ## License
158
+
159
+ MIT; see [LICENSE](LICENSE).
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ cf_share_tmux.py
4
+ pyproject.toml
5
+ cf_share_tmux.egg-info/PKG-INFO
6
+ cf_share_tmux.egg-info/SOURCES.txt
7
+ cf_share_tmux.egg-info/dependency_links.txt
8
+ cf_share_tmux.egg-info/entry_points.txt
9
+ cf_share_tmux.egg-info/top_level.txt
10
+ tests/test_cli.py
11
+ tests/test_session.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cf-share-tmux = cf_share_tmux:main
@@ -0,0 +1 @@
1
+ cf_share_tmux