Compare commits

...

174 commits

Author SHA1 Message Date
neil
ac919516f4 add DragonflyBSD by https://github.com/vmactions/dragonflybsd-vm 2022-08-06 21:30:02 -04:00
neil
6cb27ead4e fix NetBSD.yml 2022-08-06 21:30:02 -04:00
neil
15001bfa77 fix 2022-08-06 21:30:02 -04:00
neil
3efc8496cc fix Ubuntu.yml 2022-08-06 21:30:02 -04:00
neil
2ff8bc134d fix Ubuntu.yml 2022-08-06 21:30:02 -04:00
neil
9a1aa9ae9d add Ubuntu.yml 2022-08-06 21:30:02 -04:00
neil
17fcc8b76d fix MacOS.yml 2022-08-06 21:30:02 -04:00
neil
7c0bbf3e16 fix MacOS.yml 2022-08-06 21:30:02 -04:00
neil
05a849ba2b fix MacOS.yml 2022-08-06 21:30:02 -04:00
neil
fde4b58228 add MacOS.yml 2022-08-06 21:30:02 -04:00
neil
17d4a8a7df fix OpenBSD.yml 2022-08-06 21:30:02 -04:00
neil
ef11a7b30e fix OpenBSD.yml 2022-08-06 21:30:02 -04:00
neil
577e04df6c fix 2022-08-06 21:30:02 -04:00
neil
b1079b4393 add OpenBSD build by https://github.com/vmactions/openbsd-vm 2022-08-06 21:30:02 -04:00
neil
a258907cf8 add NetBSD test by https://github.com/vmactions/netbsd-vm 2022-08-06 21:30:02 -04:00
neil
169eb64b99 Add FreeBSD build by https://github.com/vmactions/freebsd-vm 2022-08-06 21:30:02 -04:00
Max Schmitt
be4a88507e chore: add FUNDING.yml 2022-03-05 23:28:29 -05:00
n0vember
c9ec7af632 add basic information for -a option in man page and help text 2021-03-21 15:39:14 -04:00
Sergio de Almeida Cipriano Junior
808b564564 Update manpage 2021-03-21 15:38:58 -04:00
Sergio de Almeida Cipriano Junior
e5ce3f04d2 Fix typo in ssh client 2021-03-21 15:38:58 -04:00
hpcbjdic
8123fa34f8 enable redefinition of TMUX_CONF
Without the added #ifndef / #endif it's not possible to _actually_ redefine TMUX_CONF by means of the compiler flag -DTMUX_CONF=... as done by the build system.
The same patch has also been applied to tmux, cf. master at https://github.com/tmux/tmux/blob/master/tmux.h.
2021-03-21 13:45:58 -04:00
Björn Jacke
f6a4ae6042 client: set IPTOS_LOWDELAY on TCP connection
this helps edge routers to prioritize our interactive network traffic.
2021-02-20 17:12:25 -05:00
Nicolas Viennot
cbec43f56d Better debugging when keys are not matching 2020-04-14 18:22:04 -04:00
Klemens Nanni
339e6c4357 Include <errno.h> for global errno
At least on OpenBSD the symbol `errno` is otherwise not defined;  it is
used in the `SSO()` macro and `send_authorized_keys()` function.
2020-04-12 15:17:50 -04:00
Nicolas Viennot
9e3e39d66d Avoid initializing stdout twice
Closes #190
2020-03-11 11:30:33 -04:00
Damian Szymański
ba6ac3a363 Update paths in build_static_release script (#178) 2019-12-06 06:43:04 -05:00
Nicolas Viennot
46564a0311
Merge pull request #177 from travis-ci/master
Add build on s390x and ppc64le
2019-12-04 20:32:22 -05:00
Damian Szymański
cc01f3f13a
Add build on s390x and ppc64le 2019-11-29 14:08:06 +01:00
Nicolas Viennot
f0a4707ef3 Update dockerfile for size 2019-11-28 16:35:48 -05:00
Nicolas Viennot
5e00bfa5e1 Rephrase 2019-11-16 17:09:38 -05:00
Nicolas Viennot
f895fe01b1 Rename account-key -> api-key 2019-11-10 22:27:23 -05:00
Nicolas Viennot
9fe8b32293 Add foreground tip 2019-11-10 16:40:36 -05:00
Nicolas Viennot
7e02dba7ef Minor refactor 2019-11-10 16:40:36 -05:00
Nicolas Viennot
bfa3c104d7 Refactor static builds 2019-11-10 16:12:12 -05:00
Nicolas Viennot
e5f6e68fad Unify tmate-debug.c with tmate-ssh-server 2019-11-10 16:12:12 -05:00
Nicolas Viennot
9fc6e96444 Send uname 2019-11-10 16:12:12 -05:00
Nicolas Viennot
86ec8d1ad6 Better crash messages 2019-11-10 03:59:12 -05:00
Nicolas Viennot
2b86031308 Fix keepalive bug 2019-11-10 03:58:59 -05:00
Nicolas Viennot
2b14611544 Polish session messages 2019-11-07 13:45:10 -05:00
Nicolas Viennot
d3c8808b0f Version bump 2019-11-07 11:38:54 -05:00
Nicolas Viennot
8b62c54748 Fix typo 2019-11-07 11:29:28 -05:00
Nicolas Viennot
ba860b8f45 Cleanup warnings 2019-11-07 10:14:03 -05:00
Nicolas Viennot
1600a81e58 Also add crash info on SIGABRT 2019-11-07 10:14:03 -05:00
Nicolas Viennot
0272757aa5 Clarify user message 2019-11-07 10:13:45 -05:00
Nicolas Viennot
9781946a70 Show initial message in copy mode 2019-11-05 21:39:16 -05:00
Nicolas Viennot
442143cd90 Show message when restarting shell 2019-11-05 21:39:16 -05:00
Nicolas Viennot
c71307ed5c Fix reconnection hanging bugs 2019-11-05 20:30:49 -05:00
Nicolas Viennot
fa49dc980d Provide a better CLI help (-h) 2019-11-05 20:30:49 -05:00
Nicolas Viennot
206c0f38b4 Set boot options via tmux commands 2019-11-05 20:30:40 -05:00
Nicolas Viennot
19341bc544 Add authorized_keys option -a 2019-11-05 20:30:11 -05:00
Nicolas Viennot
c78198dc59 Add command line arguments to set the account_key/session_names
-k account_key -n session_name -r session_name_ro
2019-11-04 18:36:10 -05:00
Nicolas Viennot
c63c8fbf90 Only use tmate.conf, not .tmux.conf
Fixes #108
2019-11-04 18:36:10 -05:00
Nicolas Viennot
6e84bab68c Add foreground mode with -F 2019-11-04 18:36:10 -05:00
Nicolas Viennot
7f693a97ae Add options for customizing session names (WIP) 2019-10-21 02:36:52 -04:00
Nicolas Viennot
4efe25d91d During SSH authentication, try the none auth method first 2019-10-15 03:11:26 -04:00
Nicolas Viennot
7262aead73 Bump to version 2.3.1 2019-10-12 21:10:03 -04:00
Nicolas Viennot
7153958e99 Allow the use of C.UTF-8 locale 2019-10-12 21:10:03 -04:00
Nicolas Viennot
74ff522983 Build static build releases on travis-ci 2019-10-12 20:38:36 -04:00
Nicolas Viennot
44635e752d Use docker to build static releases
Static builds are possible with the musl C library.
glibc is capricious when it comes to static linking and DNS support (and
other things).
2019-10-12 13:50:27 -04:00
Nicolas Viennot
d654ff2219 Send TMATE_READY message when the config files are done loading
This fixes bug where webhooks are not registering correctly, leading to
a disconnect and reconnect.
2019-09-18 23:35:07 -04:00
Nicolas Viennot
3e5d919b14 Bump to version 2.3.0 2019-07-31 21:02:18 -04:00
Andreas Schneider
4e7caeb536 ssh-client: Use ssh_get_server_publickey() if possible 2019-07-30 09:57:28 -04:00
Andreas Schneider
e25ab3cc8b ssh-client: Add missing ecdsa keytypes of libssh 0.9 2019-07-30 09:39:25 -04:00
Christian Hesse
299c7c670c add new channel after authentication
With libssh commit 8a885f0b ("channels: Add check if we are authenticated
before we create a channel") connection fails if channel is added before
successful authentication. So add the channel after authentication.

Fixes #154
2019-07-30 09:38:02 -04:00
Andreas Schneider
fd4ac27d59 ssh-client: Don't use keys from the ssh-agent
Fixes #138

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-09 08:15:07 -04:00
Nicolas Viennot
32d48cbc9d Update ed25519 server key (not yet in production) 2019-04-07 10:30:41 -04:00
Andreas Schneider
b01c6ecebd configure: Require libssh >= 0.8.4
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-07 10:30:41 -04:00
Andreas Schneider
b645ce15cb ssh-client: Add support for ed25519 keys
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-07 10:30:41 -04:00
Andreas Schneider
2ffcbbd185 ssh-client: Use SHA256 finger prints
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-07 10:30:41 -04:00
Nicolas Viennot
72ddb7eb08
Merge pull request #139 from teancom/update-man
Update MAN page to properly reference tmate where applicable
2018-12-01 12:28:52 -05:00
David Bishop
25f6a934cf Update MAN page to properly reference tmate where applicable
While there are still plenty of places where tmate uses tmux, including
config files and environment variables, I have updated the various
examples to use tmate where applicable.
2018-10-23 17:39:10 -06:00
Natanael Copa
3f6c6d4447 Fix building with or without backtrace(3)
backtrace(3) and execinfo.h are GNU extensions and may or may not be
available, and they may be provided via libexecinfo.

Fix detection of libexecinfo and allow building without any support of
backtrace, in which case we let kernel create core dump.

Fixes #116 #117
2017-09-28 08:56:41 -04:00
Nicolas Viennot
608763a41a Attempt to fix environment related crash
Fixes #89
2016-06-14 17:08:58 -04:00
Nicolas Viennot
b27f3bacc0 Crash fix in search prev/next match
Fixes #87
2016-06-10 18:00:50 -04:00
Nicolas Viennot
27169b7c07 Add missing incldues for FreeBSD 2016-06-05 12:54:25 -04:00
Nicolas Viennot
fe81322cc4 Keep alive the socket to make reconnections work properly 2016-04-21 16:20:27 -04:00
Nicolas Viennot
d433fe6956 nits 2016-03-29 01:42:07 -04:00
Nicolas Viennot
e840ff7582 Version Bump 2016-03-28 23:30:07 -04:00
Nicolas Viennot
c9813a8c42 Provide better reconnection error message 2016-03-28 23:30:07 -04:00
Nicolas Viennot
46a29037d4 strip static builds
Fixes #79
2016-03-28 23:30:07 -04:00
Nicolas Viennot
d41b06dea2 sync tmate-protocol.h 2016-03-28 16:28:11 -04:00
Nicolas Viennot
71d31e60e6 Be less strict over msgpack message size 2016-03-28 16:27:09 -04:00
Nicolas Viennot
02694d2a96 Send commands with their arguments in an array 2016-03-28 02:18:09 -04:00
Nicolas Viennot
c88870b0a3 Revert "Escape sent commands"
This reverts commit 37c71cfe15.
2016-03-28 01:22:48 -04:00
Nicolas Viennot
78305a7077 Cleanup socket 2016-03-27 13:09:04 -04:00
Nicolas Viennot
1ade196fb2 Default tmate messages to 15s 2016-03-27 13:09:04 -04:00
Nicolas Viennot
9b5bb8390c better error message 2016-03-27 02:29:43 -04:00
Nicolas Viennot
b88f66192f Merge remote-tracking branch 'tmux/master' 2016-03-27 02:15:29 -04:00
Nicolas Viennot
37c71cfe15 Escape sent commands 2016-03-27 02:06:56 -04:00
Nicolas Viennot
474487c33e Replay commands 2016-03-27 01:10:23 -04:00
Nicolas Viennot
a7c5507464 snapshot 2016-03-27 00:30:20 -04:00
Nicolas Viennot
cdfb6d7ef1 Reconnect wip 2016-03-26 19:00:16 -04:00
Nicholas Marriott
5658b628b9 Look for utempter_add_record to be sure we have the new utempter API, the old
utempter API was also using utempter.h.
2016-03-26 20:17:17 +00:00
Nicholas Marriott
b429a00cce Add to TODO. 2016-03-20 08:14:14 +00:00
Thomas Adam
410ccce4a3 Merge branch 'obsd-master' 2016-03-18 16:01:15 +00:00
nicm
312a7a1e62 Make scrolling behaviour more sensible and maintain cursor position, as
if the same had been done line-by-line. From Michal Mazurek.
2016-03-18 14:27:24 +00:00
Thomas Adam
ed598e9fe1 Merge branch 'obsd-master' 2016-03-18 08:01:18 +00:00
nicm
fa97b0a95b Instead of reusing MouseUp at the finish of a drag, add a new key
MouseDragEnd. It can be useful to bind them separately in copy mode.
2016-03-18 07:28:27 +00:00
Nicholas Marriott
3dfc79fb09 Tweak a comment. 2016-03-17 15:11:40 +00:00
Nicolas Viennot
cc20e826e0 Add webhook options 2016-03-11 14:11:48 -05:00
Nicolas Viennot
9742aeaf9b Send a ready packet when initialization is done 2016-03-11 14:11:28 -05:00
Nicolas Viennot
0d4aaa6def Fix compile warning 2016-03-11 13:28:49 -05:00
Nicolas Viennot
87794a3adb Merge remote-tracking branch 'tmux/master' 2016-03-11 13:26:22 -05:00
Thomas Adam
5fc5c03dad Merge branch 'obsd-master'
Conflicts:
	tmux.c
2016-03-05 17:58:12 +00:00
nicm
0d6de44a37 If setlocale("en_US.UTF-8") succeeds, then don't do the check for UTF-8
locale since if it isn't UTF-8 the system is broken anyway. If it fails,
try "" and check for UTF-8 with nl_langinfo(CODESET) rather than
wcwidth(). Based on a diff from schwarze@, nl_langinfo also suggested by
stsp@.
2016-03-05 16:08:38 +00:00
Thomas Adam
81f78f0da7 Merge branch 'obsd-master' 2016-03-05 10:01:09 +00:00
nicm
c38e0a4bbc Do not use c->cwd or s->cwd if it is NULL, found by Ben Boeckel. 2016-03-05 07:47:52 +00:00
nicm
1f0b317088 Although we always have en_US.UTF-8 on OpenBSD, some platforms do not,
so fall back to setlocale(LC_CTYPE, ""). tmux requires a UTF-8 locale,
so check with wcwidth() on a UTF-8 character after setlocale().
2016-03-05 07:44:31 +00:00
Thomas Adam
6c35d17800 Merge branch 'obsd-master' 2016-03-03 16:01:11 +00:00
nicm
df0983af39 show-* and set-* need to handle a missing target. 2016-03-03 14:15:22 +00:00
nicm
fa81d838da Accept clients as sessions in cmd_find_get_session. 2016-03-03 14:14:46 +00:00
Thomas Adam
45d62482da Merge branch 'obsd-master' 2016-03-03 14:01:10 +00:00
nicm
bcb41a09b3 RGB colours shouldn't be mixed up with aixterm colours, return before
that happens when working out if they are supported.
2016-03-03 12:58:15 +00:00
Nicholas Marriott
9e2fbb31ec +wchar.h 2016-03-02 18:19:13 +00:00
Nicholas Marriott
985504ff2c Merge branch 'next' 2016-03-02 18:16:51 +00:00
Thomas Adam
e304673c65 Merge branch 'obsd-master'
Conflicts:
	utf8.c
2016-03-02 18:10:51 +00:00
nicm
b8a102d26f Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.
2016-03-02 15:36:02 +00:00
nicm
d980d965dd Limit x, y and b to 0x7ff for UTF-8 mouse input, suggested by schwarze@. 2016-03-02 15:33:36 +00:00
nicm
f0239a8fe9 Remove some more unused variables, and use RB_FOREACH_SAFE in
key_bindings_unref_table.
2016-03-01 12:06:07 +00:00
nicm
2e4503ad4e Redraw status on mode entry and exit. 2016-03-01 12:05:15 +00:00
nicm
54ea8f74ae When a mouse drag is finished, fire a MouseUp key press, instead of
doing the drag end in code. From Stephen Coakley.
2016-03-01 12:04:43 +00:00
nicm
e647eeb0c9 Remove unused variables, from Michal Mazurek. 2016-03-01 12:02:54 +00:00
nicm
26945d7956 Use system wcwidth() instead of carrying around UTF-8 width tables. 2016-03-01 12:02:08 +00:00
nicm
c7851e0ee7 Fix break-pane synopsis and some other tmux.1 bits. 2016-03-01 11:58:45 +00:00
Nicholas Marriott
a011b67f56 Remove unused variables. 2016-02-19 16:45:35 +00:00
Nicholas Marriott
c3f93e7178 Add to TODO. 2016-02-19 16:45:15 +00:00
Nicholas Marriott
931b1c6d59 Merge branch 'master' into next 2016-02-19 13:37:18 +00:00
Nicholas Marriott
e9d369a09e Fixed fgetln(3) implementation (from Joerg Jung) which does not depend on *BSD
fgets(3) semantics.
2016-02-19 13:35:46 +00:00
Nicholas Marriott
6adf561507 Redraw status on mode entry and exit. 2016-02-19 13:29:59 +00:00
Nicholas Marriott
95adc0e6ba When a mouse drag is finished, fire a MouseUp key press, instead of doing the
drag end in code. From Stephen Coakley.
2016-02-19 13:28:03 +00:00
Nicholas Marriott
02753ba9ea Remove unused variables, from Michal Mazurek. 2016-02-19 13:15:22 +00:00
Nicholas Marriott
acc1090e77 Use system wcwidth() instead of carrying around UTF-8 width tables. 2016-02-19 13:14:17 +00:00
Nicholas Marriott
fc864529f5 Remove malloc_options debug bit (already gone from OpenBSD). 2016-02-19 13:11:10 +00:00
Nicholas Marriott
782dd941da Fire SIGCHLD after utempter_add_record since it probably eats it. 2016-02-17 23:21:58 +00:00
Thomas Adam
ba8290aeae Merge branch 'obsd-master' 2016-02-12 14:01:14 +00:00
nicm
4f6bc0a0a9 Expand client formats in run-shell. 2016-02-12 12:24:52 +00:00
Thomas Adam
f7c8f1ae29 xmalloc: define __bounded__ where necessary 2016-02-07 00:04:46 +00:00
Thomas Adam
ba97ae1737 EXTRA_DIST: add example_tmux.conf / xmalloc.h 2016-02-06 19:04:21 +00:00
Thomas Adam
7669cfb330 Merge branch 'obsd-master' 2016-02-05 12:01:10 +00:00
nicm
bc0c9c7920 Do not wrap cursor at start or end of history, from Michal Mazurek. 2016-02-05 10:20:06 +00:00
Nicholas Marriott
07c23ccc05 Merge branch 'master' of github.com:tmux/tmux 2016-02-05 10:08:55 +00:00
Nicholas Marriott
2130a07b70 Add to TODO. 2016-02-05 10:08:39 +00:00
Thomas Adam
26f899be10 Merge branch 'obsd-master' 2016-02-04 16:01:13 +00:00
nicm
bdb8bb790e Set up -t flag properly when passing new-session -A off to
attach-session, GitHub issue 295.
2016-02-04 14:11:20 +00:00
Thomas Adam
8760f877e1 Merge branch 'obsd-master' 2016-01-31 16:01:09 +00:00
nicm
97882f9ce2 Clear RGB flags during selection. 2016-01-31 14:11:49 +00:00
Thomas Adam
5fce21728e Merge branch 'obsd-master' 2016-01-31 12:01:09 +00:00
nicm
fa64b89ad7 Whoops, need this for the previous reverse trim commit too. 2016-01-31 09:57:41 +00:00
nicm
49e9f93738 Add RGB escape sequences for capture-pane -e. 2016-01-31 09:57:09 +00:00
nicm
8028560f82 Support negative trim values (#{=-10:pane_title}) to trim from the end,
suggested by Kevin Brubeck Unhammer.
2016-01-31 09:54:46 +00:00
nicm
225a384dbb Fix new-session with -t after command flags changes, reported by Michael Graczyk. 2016-01-31 09:52:01 +00:00
Nicholas Marriott
404379049a examples/ has gone, so delete some text about it. 2016-01-29 15:45:32 +00:00
Nicholas Marriott
2a1bb91bf7 Remove old examples in favour of one example configuration file. 2016-01-29 14:53:28 +00:00
Nicholas Marriott
a33bb3e876 Link to the bash(1) completion file from README rather than including it in
examples.
2016-01-29 14:40:30 +00:00
Thomas Adam
8cf1504ba6 Merge branch 'obsd-master' 2016-01-29 12:01:16 +00:00
nicm
427b820426 Support for RGB colour, using the extended cell mechanism to avoid
wasting unnecessary space. The 'Tc' flag must be set in the external
TERM entry (using terminal-overrides or a custom terminfo entry), if not
tmux will map to the closest of the 256 or 16 colour palettes.

Mostly from Suraj N Kurapati, based on a diff originally by someone else.
2016-01-29 11:13:56 +00:00
Nicholas Marriott
1d6bd50343 libevent.org URL. 2016-01-29 10:58:08 +00:00
Nicolas Viennot
405cd82a82 Don't abort on unknown messages 2016-01-23 01:07:25 -05:00
Nicolas Viennot
64e14eaff5 Avoid crashes when the ssh connction dies
We might want to deal with reconnections soon
2016-01-23 00:52:35 -05:00
Nicholas Marriott
ca29dc9abc Update my email address. 2016-01-19 18:07:25 +00:00
Thomas Adam
dc42c35f1f Merge branch 'obsd-master' 2016-01-19 18:01:15 +00:00
nicm
b5b5221c13 Split out getting the current state from the target search so it can be
replaced if we already know the current.
2016-01-19 16:01:30 +00:00
nicm
995af0e2b7 I no longer use my SourceForge address so replace it. 2016-01-19 15:59:12 +00:00
Thomas Adam
5d21faa99c Merge branch 'obsd-master' 2016-01-16 02:01:10 +00:00
nicm
c9815307eb Add hooks for alerts (bell, silence, activity), from Thomas Adam. 2016-01-16 00:36:53 +00:00
Nicolas Viennot
c1846177fc Cleanup hacks around ev_ssh.ev_flags
Fixes #69

Fix suggested by Leon M. George <leon@georgemail.eu>
2016-01-15 16:03:57 -05:00
Thomas Adam
506adf3764 Merge branch 'obsd-master' 2016-01-15 12:01:11 +00:00
nicm
d551ab8e5c Clear the environment properly by looping until it is empty rather than
looping over it (which may skip entries), from Brad King.
2016-01-15 11:33:41 +00:00
nicm
68d797587e A couple of missing printflike attributes, from Andrey Starodubtsev. 2016-01-15 11:31:47 +00:00
Nicolas Viennot
6dc58ab6de Lower the required glib version to 2.8 for static builds 2016-01-11 02:54:09 -08:00
Nicolas Viennot
a2520da195 Fix static compilation (libc should be dynamically linked) 2016-01-10 14:17:06 -08:00
Nicolas Viennot
3a73f17354 Allow static linking 2016-01-09 22:00:28 -05:00
Thomas Adam
ea9873e60e Merge branch 'obsd-master' 2016-01-02 18:01:12 +00:00
nicm
cfb78654c2 clock-mode needs CMD_PANE. 2016-01-02 17:16:25 +00:00
165 changed files with 2745 additions and 1765 deletions

1
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1 @@
github: nviennot

41
.github/workflows/DragonflyBSD.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: DragonflyBSD
on:
push:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/DragonflyBSD.yml'
pull_request:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/DragonflyBSD.yml'
jobs:
DragonflyBSD:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- uses: vmactions/dragonflybsd-vm@v0
with:
prepare: |
pkg install -y automake autoconf libtool pkgconf libevent msgpack libssh gsed
usesh: true
run: |
gsed -i "s/OK/0/g" tty-term.c
autoupdate
./autogen.sh
./configure
make
make install

40
.github/workflows/FreeBSD.yml vendored Normal file
View file

@ -0,0 +1,40 @@
name: FreeBSD
on:
push:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/FreeBSD.yml'
pull_request:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/FreeBSD.yml'
jobs:
FreeBSD:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- uses: vmactions/freebsd-vm@v0
with:
prepare: |
pkg install -y automake autoconf libtool pkgconf libevent msgpack libssh
usesh: true
run: |
autoupdate
./autogen.sh
./configure
make
make install

37
.github/workflows/MacOS.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: MacOS
on:
push:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/MacOS.yml'
pull_request:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/MacOS.yml'
jobs:
MacOS:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- run: |
brew install automake msgpack libssh
autoupdate
./autogen.sh
./configure
make
make install

40
.github/workflows/NetBSD.yml vendored Normal file
View file

@ -0,0 +1,40 @@
name: NetBSD
on:
push:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/NetBSD.yml'
pull_request:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/NetBSD.yml'
jobs:
NetBSD:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- uses: vmactions/netbsd-vm@v0
with:
prepare: |
pkg_add automake autoconf libtool pkgconf libevent msgpack libssh
usesh: true
run: |
autoupdate
./autogen.sh
./configure
make
make install

50
.github/workflows/OpenBSD.yml vendored Normal file
View file

@ -0,0 +1,50 @@
name: OpenBSD
on:
push:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/OpenBSD.yml'
pull_request:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/OpenBSD.yml'
jobs:
OpenBSD:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- uses: vmactions/openbsd-vm@v0
with:
prepare: |
pkg_add automake-1.16.3 autoconf-2.71 libtool pkgconf libevent msgpack libssh curl
usesh: true
run: |
sed -i 's,<event.h>,<event2/event.h>,' *.[ch]
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-Makefile_am | patch
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-server_c | patch
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-tmate-debug_c | patch
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-tmate_h | patch
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-tmux_c | patch
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-tmux_h | patch
curl https://raw.githubusercontent.com/openbsd/ports/master/sysutils/tmate/patches/patch-osdep-openbsd_c | patch
export AUTOMAKE_VERSION=1.16
export AUTOCONF_VERSION=2.71
autoupdate
./autogen.sh
./configure
make
make install

37
.github/workflows/Ubuntu.yml vendored Normal file
View file

@ -0,0 +1,37 @@
name: Ubuntu
on:
push:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/Ubuntu.yml'
pull_request:
branches:
- '*'
paths:
- '**.c'
- '**.h'
- 'compat/*'
- '.github/workflows/Ubuntu.yml'
jobs:
Ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
sudo apt-get install -y build-essential automake libtool libevent-dev libncurses5-dev libmsgpack-dev libssh-dev pkg-config
autoupdate
ACLOCAL_PATH=/usr/share/aclocal ./autogen.sh
./configure
make
sudo make install

5
.gitignore vendored
View file

@ -21,3 +21,8 @@ cscope.*
ctags
*.log
tmate.1.*
downloads/
ext/
libssh-*/
msgpack-*/
releases/

View file

@ -1,10 +1,40 @@
language: c
services:
- docker
matrix:
include:
- compiler: gcc
- compiler: clang
env: CFLAGS="-g -O2"
before_install:
- sudo apt-get update -qq
- sudo apt-get -y install debhelper autotools-dev dh-autoreconf file libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential
script: (CFLAGS= ./autogen.sh) && ./configure --enable-debug && make
include:
- arch: amd64
env: PLATFORM=amd64
- arch: amd64
env: PLATFORM=i386
- arch: arm64
env: PLATFORM=arm32v6
- arch: arm64
env: PLATFORM=arm32v7
- arch: arm64
env: PLATFORM=arm64v8
- arch: s390x
env: PLATFORM=s390x
- arch: ppc64le
env: PLATFORM=ppc64le
script:
- 'docker build . --tag local-$PLATFORM/tmate-build --build-arg PLATFORM=$PLATFORM'
# On arch=arm64, some directories are not setup correctly, and 'ruby -S gem
# install dpl' required by the release push scripts fails.
- 'if [ "$TRAVIS_TAG" ]; then sudo chown -R $USER: /var/lib/gems /usr/local/bin; fi'
- 'if [ "$TRAVIS_TAG" ]; then ./build_static_release.sh $TRAVIS_TAG $PLATFORM; fi'
deploy:
provider: releases
api_key:
secure: T2109tjjOsrVLEpJZK/uxmO0AuDGXYFdN4AAsNTmVwu/W5dcX57Kk2TCgqDuLfD21iGGXP0U/OYHM06IfBDODBWCA9P8ASHYsenS7wIiFnvCEMbfzoAFyBMrXN2kNdM2+ho3aqc0xE2lQKOKDLxpGm5FZrzujscXXzxQjWBU5Hk=
skip_cleanup: true
overwrite: true
file_glob: true
file: releases/*.tar.*
on:
repo: tmate-io/tmate
branch: master
tags: true

37
Dockerfile Normal file
View file

@ -0,0 +1,37 @@
ARG PLATFORM=amd64
FROM ${PLATFORM}/alpine:3.10 AS build
WORKDIR /build
RUN apk add --no-cache wget cmake make gcc g++ linux-headers zlib-dev openssl-dev \
automake autoconf libevent-dev ncurses-dev msgpack-c-dev libexecinfo-dev \
ncurses-static libexecinfo-static libevent-static msgpack-c ncurses-libs \
libevent libexecinfo openssl zlib
RUN set -ex; \
mkdir -p /src/libssh/build; \
cd /src; \
wget -O libssh.tar.xz https://www.libssh.org/files/0.9/libssh-0.9.0.tar.xz; \
tar -xf libssh.tar.xz -C /src/libssh --strip-components=1; \
cd /src/libssh/build; \
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
-DWITH_SFTP=OFF -DWITH_SERVER=OFF -DWITH_PCAP=OFF \
-DWITH_STATIC_LIB=ON -DWITH_GSSAPI=OFF ..; \
make -j $(nproc); \
make install
COPY compat ./compat
COPY *.c *.h autogen.sh Makefile.am configure.ac ./
RUN ./autogen.sh && ./configure --enable-static
RUN make -j $(nproc)
RUN objcopy --only-keep-debug tmate tmate.symbols && chmod -x tmate.symbols && strip tmate
RUN ./tmate -V
FROM alpine:3.9
RUN apk --no-cache add bash
RUN mkdir /build
ENV PATH=/build:$PATH
COPY --from=build /build/tmate.symbols /build
COPY --from=build /build/tmate /build

View file

@ -6,8 +6,8 @@ CLEANFILES = tmate.1.mdoc tmate.1.man
# Distribution tarball options.
EXTRA_DIST = \
CHANGES FAQ README TODO COPYING examples compat/*.[ch] \
array.h compat.h tmux.h tmate.h osdep-*.c mdoc2man.awk tmate.1
CHANGES FAQ README TODO COPYING example_tmux.conf compat/*.[ch] \
array.h compat.h tmux.h osdep-*.c xmalloc.h mdoc2man.awk tmate.1
dist-hook:
make clean
grep "^#found_debug=" configure
@ -33,8 +33,8 @@ CFLAGS += -g
CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2
CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations
CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare
CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align
CFLAGS += -Wdeclaration-after-statement -Wno-pointer-sign -Wno-attributes
CFLAGS += -Wundef -Wbad-function-cast -Winline
CFLAGS += -Wno-pointer-sign -Wno-attributes
CPPFLAGS += -DDEBUG
endif
if IS_COVERAGE
@ -44,6 +44,9 @@ endif
CPPFLAGS += -iquote.
endif
CFLAGS += -Wno-unused-parameter -Wno-unused-variable -Wno-null-pointer-arithmetic
CFLAGS += -Wno-deprecated-declarations -Wno-format-nonliteral
# Set flags for Solaris.
if IS_SUNOS
if IS_GCC
@ -58,7 +61,7 @@ if IS_SUNCC
CFLAGS += -erroff=E_EMPTY_DECLARATION
endif
# Set _LINUX_SOURCE_COMPAT for AIX for mallocing 0 bytes
# Set _LINUX_SOURCE_COMPAT for AIX for malloc(0).
if IS_AIX
DEFS += -D_LINUX_SOURCE_COMPAT=1
endif

15
README
View file

@ -8,7 +8,7 @@ This release runs on OpenBSD, FreeBSD, NetBSD, Linux, OS X and Solaris.
tmux depends on libevent 2.x. Download it from:
http://www.monkey.org/~provos/libevent/
http://libevent.org
To build tmux from a release tarball, do:
@ -33,13 +33,17 @@ the source tree with:
Some common questions are answered in the FAQ file and a more extensive (but
slightly out of date) guide is available in the OpenBSD FAQ at
http://www.openbsd.org/faq/faq7.html#tmux. A rough todo list is in the TODO
file and some example configurations are in the examples directory.
file and an example configuration in example_tmux.conf.
A vim(1) syntax file is available at:
https://github.com/keith/tmux.vim
https://raw.githubusercontent.com/keith/tmux.vim/master/syntax/tmux.vim
And a bash(1) completion file at:
https://github.com/przepompownia/tmux-bash-completion
For debugging, running tmux with -v or -vv will generate server and client log
files in the current directory.
@ -56,10 +60,7 @@ welcome. Please send by email to:
tmux-users@googlegroups.com
This file and the CHANGES, FAQ, SYNCING and TODO files are licensed under
the ISC license. Files under examples/ remain copyright their authors unless
otherwise stated in the file but permission has been received to distribute
them with tmux. All other files have a license and copyright notice at their
start.
This file and the CHANGES, FAQ, SYNCING and TODO files are licensed under the
ISC license. All other files have a license and copyright notice at their start.
-- Nicholas Marriott <nicholas.marriott@gmail.com>

26
TODO
View file

@ -62,6 +62,20 @@
* command to toggle selection not to move it in copy-mode
* regex searching
* copy-pipe should have -x as well
* copy mode key bindings should just be a standard key table, using
something like "copy-mode start-selection"; it could use
command-prompt for search, goto, etc:
bind -Temacs command-prompt -p'Search Up: ' 'copy-mode search-up %%'
it'd need a separate lookup, because modes are per-pane, perhaps a
table() cb to give the table name ("vi" or "emacs"). anything in the
table fires the command, anything not in the table is injected as a
key
* searching in copy mode should unwrap lines, so if you seach for "foobar"
then it should be found even if it is now "foo\nbar" (if the WRAP flag
is set on the line)
* {} to go to next/previous blank line in copy mode
- layout stuff
* way to tag a layout as a number/name
@ -118,18 +132,8 @@
comes from config for new sessions and windows. likewise, panes and
jobs and run-shell and lock command all start with slightly different
environments
* multiline status line?
* multiline status line? separate command prompt and status line?
* customizable command aliases
* automatic pane logging
* BCE? We are halfway there (output side is done for pane backgrounds),
just need to change how screen/grid handles erase
* copy mode key bindings should just be a standard key table, using
something like "copy-mode start-selection"; it could use
command-prompt for search, goto, etc:
bind -Temacs command-prompt -p'Search Up: ' 'copy-mode search-up %%'
it'd need a separate lookup, because modes are per-pane, perhaps a
table() cb to give the table name ("vi" or "emacs"). anything in the
table fires the command, anything not in the table is injected as a
key

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -29,6 +29,7 @@ int alerts_enabled(struct window *, int);
void alerts_callback(int, short, void *);
void alerts_reset(struct window *);
void alerts_run_hook(struct session *, struct winlink *, int);
int alerts_check_all(struct session *, struct winlink *);
int alerts_check_bell(struct session *, struct winlink *);
int alerts_check_activity(struct session *, struct winlink *);
@ -55,8 +56,6 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
RB_FOREACH(w, windows, &windows) {
RB_FOREACH(s, sessions, &sessions) {
if (s->flags & SESSION_UNATTACHED)
continue;
RB_FOREACH(wl, winlinks, &s->windows) {
if (wl->window != w)
continue;
@ -73,6 +72,22 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
alerts_fired = 0;
}
void
alerts_run_hook(struct session *s, struct winlink *wl, int flags)
{
struct cmd_find_state fs;
if (cmd_find_from_winlink(&fs, s, wl) != 0)
return;
if (flags & WINDOW_BELL)
hooks_run(s->hooks, NULL, &fs, "alert-bell");
if (flags & WINDOW_SILENCE)
hooks_run(s->hooks, NULL, &fs, "alert-silence");
if (flags & WINDOW_ACTIVITY)
hooks_run(s->hooks, NULL, &fs, "alert-activity");
}
int
alerts_check_all(struct session *s, struct winlink *wl)
{
@ -81,8 +96,10 @@ alerts_check_all(struct session *s, struct winlink *wl)
alerts = alerts_check_bell(s, wl);
alerts |= alerts_check_activity(s, wl);
alerts |= alerts_check_silence(s, wl);
if (alerts != 0)
if (alerts != 0) {
alerts_run_hook(s, wl, alerts);
server_status_session(s);
}
return (alerts);
}

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2006 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

33
build_static_release.sh Executable file
View file

@ -0,0 +1,33 @@
#!/bin/bash
set -eux
# This is invoked by .travis.yml
VERSION=$1
PLATFORM=$2
SRC_VERSION=`cat configure.ac | grep AC_INIT | sed -E 's/^AC_INIT\(tmate, (.+)\)$/\1/'`
if [ $SRC_VERSION != $VERSION ]; then
echo "Version mismatch: $SRC_VERSION != $VERSION"
exit 1
fi
RELEASE_NAME=tmate-$VERSION-static-linux-$PLATFORM
echo "Building $RELEASE_NAME"
docker build . --tag local-$PLATFORM/tmate-build --build-arg PLATFORM=$PLATFORM
mkdir -p releases
cd releases
rm -rf $RELEASE_NAME
mkdir -p $RELEASE_NAME
docker run --rm local-$PLATFORM/tmate-build cat /build/tmate > $RELEASE_NAME/tmate
chmod +x $RELEASE_NAME/tmate
tar -cf - $RELEASE_NAME | xz > tmate-$VERSION-static-linux-$PLATFORM.tar.xz
rm -rf $RELEASE_NAME-symbols
mkdir -p $RELEASE_NAME-symbols
docker run --rm local-$PLATFORM/tmate-build cat /build/tmate.symbols > $RELEASE_NAME-symbols/tmate.symbols
tar -cf - $RELEASE_NAME-symbols | xz > dbg-symbols-tmate-$VERSION-static-linux-$PLATFORM.tar.xz

39
cfg.c
View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -71,7 +71,7 @@ start_cfg(void)
cfg_add_cause("%s: %s", TMUX_CONF, strerror(errno));
if (cfg_file == NULL && (home = find_home()) != NULL) {
xasprintf(&cfg_file, "%s/.tmux.conf", home);
xasprintf(&cfg_file, "%s/.tmate.conf", home);
if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
free(cfg_file);
cfg_file = NULL;
@ -81,20 +81,6 @@ start_cfg(void)
cfg_add_cause("%s: %s", cfg_file, cause);
free(cause);
#ifdef TMATE
cause = NULL;
if ((home = find_home()) != NULL) {
xasprintf(&tmate_cfg_file, "%s/.tmate.conf", home);
if (access(tmate_cfg_file, R_OK) != 0 && errno == ENOENT) {
free(tmate_cfg_file);
tmate_cfg_file = NULL;
}
}
if (tmate_cfg_file != NULL && load_cfg(tmate_cfg_file, cfg_cmd_q, &cause) == -1)
cfg_add_cause("%s: %s", cfg_file, cause);
free(cause);
#endif
cmdq_continue(cfg_cmd_q);
}
@ -149,6 +135,20 @@ load_cfg(const char *path, struct cmd_q *cmdq, char **cause)
return (found);
}
static void print_cfg_errors(void)
{
u_int i;
for (i = 0; i < cfg_ncauses; i++) {
tmate_info("%s", cfg_causes[i]);
free(cfg_causes[i]);
}
free(cfg_causes);
cfg_causes = NULL;
cfg_ncauses = 0;
}
void
cfg_default_done(__unused struct cmd_q *cmdq)
{
@ -157,7 +157,14 @@ cfg_default_done(__unused struct cmd_q *cmdq)
cfg_finished = 1;
#ifdef TMATE
/* We do it this late, this way, CLI options take precedence over cfg file */
tmate_load_cli_options();
tmate_session_start();
if (tmate_foreground && cfg_ncauses) {
print_cfg_errors();
exit(1);
}
#endif
if (!RB_EMPTY(&sessions))

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -32,6 +32,7 @@
#include <unistd.h>
#include "tmux.h"
#include "tmate.h"
struct tmuxproc *client_proc;
struct tmuxpeer *client_peer;
@ -213,8 +214,67 @@ client_exit_message(void)
#ifdef TMATE
extern const struct cmd_entry cmd_attach_session_entry;
extern const struct cmd_entry cmd_new_session_entry;
/* For foreground mode */
static int __argc;
static const char **__argv;
#endif
int run_headless_command(int argc, const char **argv, int flags, void (*err_callback)(const char *))
{
struct cmd_q *cmd_q;
struct cmd_list *cmdlist;
char *cause;
cmd_q = cmdq_new(NULL); /* No client */
if ((cmdlist = cmd_list_parse(argc, (char **)argv, NULL, 0, &cause)) == NULL) {
if (err_callback)
err_callback(cause);
return -1;
}
cmdq_run(cmd_q, cmdlist, NULL);
cmd_list_free(cmdlist);
cmdq_free(cmd_q);
if (flags & DEFER_ERRORS_CFG)
return 0;
/* error messages land in cfg_causes */
int ret = cfg_ncauses ? -1 : 0;
for (u_int i = 0; i < cfg_ncauses; i++) {
if (err_callback)
err_callback(cfg_causes[i]);
free(cfg_causes[i]);
}
free(cfg_causes);
cfg_causes = NULL;
cfg_ncauses = 0;
return ret;
}
static void initial_client_cmd_err_callback(const char *cause)
{
tmate_info("%s", cause);
}
void run_initial_client_cmd(void)
{
int argc = __argc;
const char **argv = __argv;
const char *default_argv[] = {"new-session"};
if (argc == 0) {
argc = 1;
argv = default_argv;
}
if (run_headless_command(argc, argv, 0, initial_client_cmd_err_callback) < 0)
exit(1);
}
/* Client main loop. */
int
client_main(struct event_base *base, int argc, char **argv, int flags,
@ -232,6 +292,8 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
size_t size;
#ifdef TMATE
int cant_nest = 0;
__argc = argc;
__argv = (const char **)argv;
#endif
/* Ignore SIGCHLD now or daemon() in the server will leave a zombie. */
@ -296,6 +358,13 @@ client_main(struct event_base *base, int argc, char **argv, int flags,
fprintf(stderr, "no server running on %s\n",
socket_path);
} else {
#ifdef TMATE
if (errno == ENOENT)
fprintf(stderr, "You must specify a socket name with -S. For example: \n"
" tmate -S /tmp/tmate.sock new-session -d\n"
" tmate -S /tmp/tmate.sock wait tmate-ready\n");
else
#endif
fprintf(stderr, "error connecting to %s (%s)\n",
socket_path, strerror(errno));
}

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -35,7 +35,7 @@ const struct cmd_entry cmd_break_pane_entry = {
.alias = "breakp",
.args = { "dPF:s:t:", 0, 0 },
.usage = "[-dP] [-F format] " CMD_SRCDST_PANE_USAGE,
.usage = "[-dP] [-F format] [-s src-pane] [-t dst-window]",
.sflag = CMD_PANE,
.tflag = CMD_WINDOW_INDEX,

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -46,6 +46,8 @@ const struct cmd_entry cmd_clock_mode_entry = {
.args = { "t:", 0, 0 },
.usage = CMD_TARGET_PANE_USAGE,
.tflag = CMD_PANE,
.flags = 0,
.exec = cmd_copy_mode_exec
};

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -400,6 +400,7 @@ int
cmd_find_get_session(struct cmd_find_state *fs, const char *session)
{
struct session *s, *s_loop;
struct client *c;
log_debug("%s: %s", __func__, session);
@ -416,6 +417,13 @@ cmd_find_get_session(struct cmd_find_state *fs, const char *session)
if (fs->s != NULL)
return (0);
/* Look for as a client. */
c = cmd_find_client(NULL, session, 1);
if (c != NULL && c->session != NULL) {
fs->s = c->session;
return (0);
}
/* Stop now if exact only. */
if (fs->flags & CMD_FIND_EXACT_SESSION)
return (-1);
@ -878,6 +886,22 @@ cmd_find_from_session(struct cmd_find_state *fs, struct session *s)
return (0);
}
/* Find state from a winlink. */
int
cmd_find_from_winlink(struct cmd_find_state *fs, struct session *s,
struct winlink *wl)
{
cmd_find_clear_state(fs, NULL, 0);
fs->s = s;
fs->wl = wl;
fs->w = wl->window;
fs->wp = wl->window->active;
cmd_find_log_state(__func__, fs);
return (0);
}
/* Find state from a window. */
int
cmd_find_from_window(struct cmd_find_state *fs, struct window *w)
@ -906,15 +930,27 @@ cmd_find_from_pane(struct cmd_find_state *fs, struct window_pane *wp)
return (0);
}
/* Find current state. */
int
cmd_find_current(struct cmd_find_state *fs, struct cmd_q *cmdq, int flags)
{
cmd_find_clear_state(fs, cmdq, flags);
if (cmd_find_current_session(fs) != 0) {
if (~flags & CMD_FIND_QUIET)
cmdq_error(cmdq, "no current session");
return (-1);
}
return (0);
}
/*
* Split target into pieces and resolve for the given type. Fills in the given
* state. Returns 0 on success or -1 on error.
*/
int
cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
const char *target, enum cmd_find_type type, int flags)
cmd_find_target(struct cmd_find_state *fs, struct cmd_find_state *current,
struct cmd_q *cmdq, const char *target, enum cmd_find_type type, int flags)
{
struct cmd_find_state current;
struct mouse_event *m;
char *colon, *period, *copy = NULL;
const char *session, *window, *pane;
@ -934,15 +970,8 @@ cmd_find_target(struct cmd_find_state *fs, struct cmd_q *cmdq,
fs->current = &marked_pane;
else if (cmd_find_valid_state(&cmdq->current))
fs->current = &cmdq->current;
else {
cmd_find_clear_state(&current, cmdq, flags);
if (cmd_find_current_session(&current) != 0) {
if (~flags & CMD_FIND_QUIET)
cmdq_error(cmdq, "no current session");
goto error;
}
fs->current = &current;
}
else
fs->current = current;
/* An empty or NULL target is the current. */
if (target == NULL || *target == '\0')
@ -1187,7 +1216,7 @@ cmd_find_client(struct cmd_q *cmdq, const char *target, int quiet)
const char *path;
/* A NULL argument means the current client. */
if (target == NULL) {
if (cmdq != NULL && target == NULL) {
c = cmd_find_current_client(cmdq);
if (c == NULL && !quiet)
cmdq_error(cmdq, "no current client");

View file

@ -73,14 +73,13 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
struct format_tree *ft;
const char *cwd;
cwd = wp->cwd;
if (cmdq->client != NULL && cmdq->client->session == NULL)
cwd = cmdq->client->cwd;
else if (s != NULL)
cwd = s->cwd;
else
cwd = NULL;
ft = format_create(cmdq, 0);
format_defaults(ft, NULL, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);

View file

@ -2,7 +2,7 @@
/*
* Copyright (c) 2011 George Nachman <tmux@georgester.com>
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -73,9 +73,9 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_WAIT);
}
if (c != NULL && c->session == NULL)
if (c != NULL && c->session == NULL && c->cwd != NULL)
cwd = c->cwd;
else if ((s = c->session) != NULL)
else if ((s = c->session) != NULL && s->cwd != NULL)
cwd = s->cwd;
else
cwd = ".";

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -68,13 +68,13 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct client *c = cmdq->client;
struct session *s, *attach_sess;
struct session *s, *as;
struct session *groupwith = cmdq->state.tflag.s;
struct window *w;
struct environ *env;
struct termios tio, *tiop;
const char *newname, *target, *update, *errstr, *template;
const char *path, *cwd, *to_free;
const char *path, *cwd, *to_free = NULL;
char **argv, *cmd, *cause, *cp;
int detached, already_attached, idx, argc;
u_int sx, sy;
@ -100,7 +100,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
cmdq_error(cmdq, "bad session name: %s", newname);
return (CMD_RETURN_ERROR);
}
if ((attach_sess = session_find(newname)) != NULL) {
if ((as = session_find(newname)) != NULL) {
if (args_has(args, 'A')) {
/*
* This cmdq is now destined for
@ -108,7 +108,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
* will have already been prepared, copy this
* session into its tflag so it can be used.
*/
cmdq->state.tflag.s = attach_sess;
cmd_find_from_session(&cmdq->state.tflag, as);
return (cmd_attach_session(cmdq,
args_has(args, 'D'), 0, NULL,
args_has(args, 'E')));
@ -118,7 +118,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
}
}
if ((target = args_get(args, 't')) == NULL)
if ((target = args_get(args, 't')) != NULL) {
if (groupwith == NULL) {
cmdq_error(cmdq, "no such session: %s", target);
goto error;
}
} else
groupwith = NULL;
/* Set -d if no client. */
@ -126,19 +131,21 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
if (c == NULL)
detached = 1;
if (tmate_foreground)
detached = 1;
/* Is this client already attached? */
already_attached = 0;
if (c != NULL && c->session != NULL)
already_attached = 1;
/* Get the new session working directory. */
to_free = NULL;
if (args_has(args, 'c')) {
ft = format_create(cmdq, 0);
format_defaults(ft, c, NULL, NULL, NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
} else if (c != NULL && c->session == NULL)
} else if (c != NULL && c->session == NULL && c->cwd != NULL)
cwd = c->cwd;
else
cwd = ".";
@ -208,7 +215,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
if (!args_has(args, 't') && args->argc != 0) {
argc = args->argc;
argv = args->argv;
} else if (target == NULL) {
} else if (groupwith == NULL) {
cmd = options_get_string(global_s_options, "default-command");
if (cmd != NULL && *cmd != '\0') {
argc = 1;
@ -257,7 +264,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
* If a target session is given, this is to be part of a session group,
* so add it to the group and synchronize.
*/
if (args_has(args, 't')) {
if (groupwith != NULL) {
session_group_add(groupwith, s);
session_group_synchronize_to(s);
session_select(s, RB_MIN(winlinks, &s->windows)->idx);

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -201,12 +201,13 @@ cmdq_continue_one(struct cmd_q *cmdq)
char *tmp;
int flags = !!(cmd->flags & CMD_CONTROL);
tmp = cmd_print(cmd);
log_debug("cmdq %p: %s", cmdq, tmp);
#ifdef TMATE
if (tmate_should_replicate_cmd(cmd->entry))
tmate_exec_cmd(tmp);
tmate_exec_cmd(cmd);
#endif
tmp = cmd_print(cmd);
log_debug("cmdq %p: %s", cmdq, tmp);
free(tmp);
cmdq->time = time(NULL);
@ -214,7 +215,7 @@ cmdq_continue_one(struct cmd_q *cmdq)
cmdq_guard(cmdq, "begin", flags);
if (cmd_prepare_state(cmd, cmdq) != 0)
if (cmd_prepare_state(cmd, cmdq, NULL) != 0)
goto error;
retval = cmd->entry->exec(cmd, cmdq);
if (retval == CMD_RETURN_ERROR)

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -68,7 +68,6 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_NORMAL);
}
w = wl->window;
if (args_has(args, 'Z')) {
if (w->flags & WINDOW_ZOOMED)
window_unzoom(w);

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
* Copyright (c) 2011 Marcel P. Partap <mpartap@gmx.net>
*
* Permission to use, copy, modify, and distribute this software for any

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -93,7 +93,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
else
cwd = NULL;
ft = format_create(cmdq, 0);
format_defaults(ft, NULL, s, wl, wp);
format_defaults(ft, cmdq->state.c, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);

View file

@ -97,9 +97,9 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
goto do_print;
}
if (c != NULL && c->session == NULL)
if (c != NULL && c->session == NULL && c->cwd != NULL)
cwd = c->cwd;
else if ((s = c->session) != NULL)
else if ((s = c->session) != NULL && s->cwd != NULL)
cwd = s->cwd;
else
cwd = ".";

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -47,7 +47,7 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct environ *env;
const char *name, *value;
const char *name, *value, *target;
name = args->argv[0];
if (*name == '\0') {
@ -64,10 +64,19 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)
else
value = args->argv[1];
if (args_has(self->args, 'g') || cmdq->state.tflag.s == NULL)
if (args_has(self->args, 'g'))
env = global_environ;
else
else {
if (cmdq->state.tflag.s == NULL) {
target = args_get(args, 't');
if (target != NULL)
cmdq_error(cmdq, "no such session: %s", target);
else
cmdq_error(cmdq, "no current session");
return (CMD_RETURN_ERROR);
}
env = cmdq->state.tflag.s->environ;
}
if (args_has(self->args, 'u')) {
if (value != NULL) {

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -100,7 +100,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
struct client *c;
const struct options_table_entry *oe;
struct options *oo;
const char *optstr, *valstr;
const char *optstr, *valstr, *target;
/* Get the option name and value. */
optstr = args->argv[0];
@ -140,29 +140,29 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
else if (oe->scope == OPTIONS_TABLE_WINDOW) {
if (args_has(self->args, 'g'))
oo = global_w_options;
else {
if (wl == NULL) {
cmdq_error(cmdq,
"couldn't set '%s'%s", optstr,
(!args_has(args, 't') && !args_has(args,
'g')) ? " need target window or -g" : "");
return (CMD_RETURN_ERROR);
}
else if (wl == NULL) {
target = args_get(args, 't');
if (target != NULL) {
cmdq_error(cmdq, "no such window: %s",
target);
} else
cmdq_error(cmdq, "no current window");
return (CMD_RETURN_ERROR);
} else
oo = wl->window->options;
}
} else if (oe->scope == OPTIONS_TABLE_SESSION) {
if (args_has(self->args, 'g'))
oo = global_s_options;
else {
if (s == NULL) {
cmdq_error(cmdq,
"couldn't set '%s'%s", optstr,
(!args_has(args, 't') && !args_has(args,
'g')) ? " need target session or -g" : "");
return (CMD_RETURN_ERROR);
}
else if (s == NULL) {
target = args_get(args, 't');
if (target != NULL) {
cmdq_error(cmdq, "no such session: %s",
target);
} else
cmdq_error(cmdq, "no current session");
return (CMD_RETURN_ERROR);
} else
oo = s->options;
}
} else {
cmdq_error(cmdq, "unknown table");
return (CMD_RETURN_ERROR);

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -93,11 +93,28 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_q *cmdq)
struct args *args = self->args;
struct environ *env;
struct environ_entry *envent;
const char *target;
if (args_has(self->args, 'g') || cmdq->state.tflag.s == NULL)
if ((target = args_get(args, 't')) != NULL) {
if (cmdq->state.tflag.s == NULL) {
cmdq_error(cmdq, "no such session: %s", target);
return (CMD_RETURN_ERROR);
}
}
if (args_has(self->args, 'g'))
env = global_environ;
else
else {
if (cmdq->state.tflag.s == NULL) {
target = args_get(args, 't');
if (target != NULL)
cmdq_error(cmdq, "no such session: %s", target);
else
cmdq_error(cmdq, "no current session");
return (CMD_RETURN_ERROR);
}
env = cmdq->state.tflag.s->environ;
}
if (args->argc != 0) {
envent = environ_find(env, args->argv[0]);

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -63,12 +63,13 @@ const struct cmd_entry cmd_show_window_options_entry = {
enum cmd_retval
cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct session *s = cmdq->state.tflag.s;
struct winlink *wl = cmdq->state.tflag.wl;
struct options *oo;
enum options_table_scope scope;
int quiet;
struct args *args = self->args;
struct session *s = cmdq->state.tflag.s;
struct winlink *wl = cmdq->state.tflag.wl;
struct options *oo;
enum options_table_scope scope;
int quiet;
const char *target;
if (args_has(self->args, 's')) {
oo = global_options;
@ -78,13 +79,27 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
scope = OPTIONS_TABLE_WINDOW;
if (args_has(self->args, 'g'))
oo = global_w_options;
else
else if (wl == NULL) {
target = args_get(args, 't');
if (target != NULL) {
cmdq_error(cmdq, "no such window: %s", target);
} else
cmdq_error(cmdq, "no current window");
return (CMD_RETURN_ERROR);
} else
oo = wl->window->options;
} else {
scope = OPTIONS_TABLE_SESSION;
if (args_has(self->args, 'g'))
oo = global_s_options;
else
else if (s == NULL) {
target = args_get(args, 't');
if (target != NULL) {
cmdq_error(cmdq, "no such session: %s", target);
} else
cmdq_error(cmdq, "no current session");
return (CMD_RETURN_ERROR);
} else
oo = s->options;
}

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -307,6 +307,10 @@ cmd_string_variable(const char *s, size_t *p)
free(buf);
if (envent == NULL)
return (xstrdup(""));
#ifdef TMATE
if (envent->value == NULL)
return (xstrdup(""));
#endif
return (xstrdup(envent->value));
error:

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -45,28 +45,23 @@ const struct cmd_entry cmd_swap_pane_entry = {
enum cmd_retval
cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct winlink *src_wl, *dst_wl;
struct window *src_w, *dst_w;
struct window_pane *tmp_wp, *src_wp, *dst_wp;
struct layout_cell *src_lc, *dst_lc;
u_int sx, sy, xoff, yoff;
dst_wl = cmdq->state.tflag.wl;
dst_w = dst_wl->window;
dst_w = cmdq->state.tflag.wl->window;
dst_wp = cmdq->state.tflag.wp;
src_wl = cmdq->state.sflag.wl;
src_w = src_wl->window;
src_w = cmdq->state.sflag.wl->window;
src_wp = cmdq->state.sflag.wp;
server_unzoom_window(dst_w);
if (args_has(self->args, 'D')) {
src_wl = dst_wl;
src_w = dst_w;
src_wp = TAILQ_NEXT(dst_wp, entry);
if (src_wp == NULL)
src_wp = TAILQ_FIRST(&dst_w->panes);
} else if (args_has(self->args, 'U')) {
src_wl = dst_wl;
src_w = dst_w;
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
if (src_wp == NULL)

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
* Copyright (c) 2013 Thiago de Arruda <tpadilha84@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any

121
cmd.c
View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -388,10 +388,23 @@ usage:
}
static int
cmd_prepare_state_flag(struct cmd_find_state *fs, enum cmd_entry_flag flag,
const char *target, struct cmd_q *cmdq)
cmd_prepare_state_flag(char c, const char *target, enum cmd_entry_flag flag,
struct cmd_q *cmdq, struct cmd_q *parent)
{
int targetflags, error;
int targetflags, error;
struct cmd_find_state *fs = NULL;
struct cmd_find_state *current = NULL;
struct cmd_find_state tmp;
if (flag == CMD_NONE ||
flag == CMD_CLIENT ||
flag == CMD_CLIENT_CANFAIL)
return (0);
if (c == 't')
fs = &cmdq->state.tflag;
else if (c == 's')
fs = &cmdq->state.sflag;
if (flag == CMD_SESSION_WITHPANE) {
if (target != NULL && target[strcspn(target, ":.")] != '\0')
@ -400,6 +413,55 @@ cmd_prepare_state_flag(struct cmd_find_state *fs, enum cmd_entry_flag flag,
flag = CMD_SESSION;
}
targetflags = 0;
switch (flag) {
case CMD_SESSION:
case CMD_SESSION_CANFAIL:
case CMD_SESSION_PREFERUNATTACHED:
if (flag == CMD_SESSION_CANFAIL)
targetflags |= CMD_FIND_QUIET;
if (flag == CMD_SESSION_PREFERUNATTACHED)
targetflags |= CMD_FIND_PREFER_UNATTACHED;
break;
case CMD_MOVEW_R:
flag = CMD_WINDOW_INDEX;
/* FALLTHROUGH */
case CMD_WINDOW:
case CMD_WINDOW_CANFAIL:
case CMD_WINDOW_MARKED:
case CMD_WINDOW_INDEX:
if (flag == CMD_WINDOW_CANFAIL)
targetflags |= CMD_FIND_QUIET;
if (flag == CMD_WINDOW_MARKED)
targetflags |= CMD_FIND_DEFAULT_MARKED;
if (flag == CMD_WINDOW_INDEX)
targetflags |= CMD_FIND_WINDOW_INDEX;
break;
case CMD_PANE:
case CMD_PANE_CANFAIL:
case CMD_PANE_MARKED:
if (flag == CMD_PANE_CANFAIL)
targetflags |= CMD_FIND_QUIET;
if (flag == CMD_PANE_MARKED)
targetflags |= CMD_FIND_DEFAULT_MARKED;
break;
default:
fatalx("unknown %cflag %d", c, flag);
}
log_debug("%s: flag %c %d %#x", __func__, c, flag, targetflags);
if (parent != NULL) {
if (c == 't')
current = &parent->state.tflag;
else if (c == 's')
current = &parent->state.sflag;
} else {
error = cmd_find_current(&tmp, cmdq, targetflags);
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
return (-1);
current = &tmp;
}
switch (flag) {
case CMD_NONE:
case CMD_CLIENT:
@ -409,61 +471,42 @@ cmd_prepare_state_flag(struct cmd_find_state *fs, enum cmd_entry_flag flag,
case CMD_SESSION_CANFAIL:
case CMD_SESSION_PREFERUNATTACHED:
case CMD_SESSION_WITHPANE:
targetflags = 0;
if (flag == CMD_SESSION_CANFAIL)
targetflags |= CMD_FIND_QUIET;
if (flag == CMD_SESSION_PREFERUNATTACHED)
targetflags |= CMD_FIND_PREFER_UNATTACHED;
error = cmd_find_target(fs, cmdq, target, CMD_FIND_SESSION,
targetflags);
if (error != 0 && flag != CMD_SESSION_CANFAIL)
error = cmd_find_target(fs, current, cmdq, target,
CMD_FIND_SESSION, targetflags);
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
return (-1);
break;
case CMD_MOVEW_R:
error = cmd_find_target(fs, cmdq, target, CMD_FIND_SESSION,
CMD_FIND_QUIET);
error = cmd_find_target(fs, current, cmdq, target,
CMD_FIND_SESSION, CMD_FIND_QUIET);
if (error == 0)
break;
flag = CMD_WINDOW_INDEX;
/* FALLTHROUGH */
case CMD_WINDOW:
case CMD_WINDOW_CANFAIL:
case CMD_WINDOW_MARKED:
case CMD_WINDOW_INDEX:
targetflags = 0;
if (flag == CMD_WINDOW_CANFAIL)
targetflags |= CMD_FIND_QUIET;
if (flag == CMD_WINDOW_MARKED)
targetflags |= CMD_FIND_DEFAULT_MARKED;
if (flag == CMD_WINDOW_INDEX)
targetflags |= CMD_FIND_WINDOW_INDEX;
error = cmd_find_target(fs, cmdq, target, CMD_FIND_WINDOW,
targetflags);
if (error != 0 && flag != CMD_WINDOW_CANFAIL)
error = cmd_find_target(fs, current, cmdq, target,
CMD_FIND_WINDOW, targetflags);
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
return (-1);
break;
case CMD_PANE:
case CMD_PANE_CANFAIL:
case CMD_PANE_MARKED:
targetflags = 0;
if (flag == CMD_PANE_CANFAIL)
targetflags |= CMD_FIND_QUIET;
if (flag == CMD_PANE_MARKED)
targetflags |= CMD_FIND_DEFAULT_MARKED;
error = cmd_find_target(fs, cmdq, target, CMD_FIND_PANE,
targetflags);
if (error != 0 && flag != CMD_PANE_CANFAIL)
error = cmd_find_target(fs, current, cmdq, target,
CMD_FIND_PANE, targetflags);
if (error != 0 && ~targetflags & CMD_FIND_QUIET)
return (-1);
break;
default:
fatalx("unknown %cflag %d", c, flag);
}
return (0);
}
int
cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq)
cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq, struct cmd_q *parent)
{
const struct cmd_entry *entry = cmd->entry;
struct cmd_state *state = &cmdq->state;
@ -503,14 +546,14 @@ cmd_prepare_state(struct cmd *cmd, struct cmd_q *cmdq)
s = args_get(cmd->args, 't');
log_debug("preparing -t state: target %s", s == NULL ? "none" : s);
error = cmd_prepare_state_flag(&state->tflag, entry->tflag, s, cmdq);
error = cmd_prepare_state_flag('t', s, entry->tflag, cmdq, parent);
if (error != 0)
return (error);
s = args_get(cmd->args, 's');
log_debug("preparing -s state: target %s", s == NULL ? "none" : s);
error = cmd_prepare_state_flag(&state->sflag, entry->sflag, s, cmdq);
error = cmd_prepare_state_flag('s', s, entry->sflag, cmdq, parent);
if (error != 0)
return (error);

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2006 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -52,6 +52,8 @@
#include <stdlib.h>
#include <string.h>
#include "compat.h"
#define Assert(Cond) if (!(Cond)) abort()
static const char Base64[] =
@ -122,7 +124,7 @@ static const char Pad64 = '=';
*/
int
b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
b64_ntop(const char *src, size_t srclength, char *target, size_t targsize) {
size_t datalength = 0;
uint8_t input[3];
uint8_t output[4];

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013 Dagobert Michelsen
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,43 +1,26 @@
/* $NetBSD: fgetln.c,v 1.3 2007/08/07 02:06:58 lukem Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
/*
* Copyright (c) 2015 Joerg Jung <jung@openbsd.org>
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas.
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
/*
* portable fgetln() version, NOT reentrant
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "tmux.h"
@ -45,41 +28,34 @@ char *
fgetln(FILE *fp, size_t *len)
{
static char *buf = NULL;
static size_t bufsiz = 0;
char *ptr;
static size_t bufsz = 0;
size_t r = 0;
char *p;
int c, e;
if (buf == NULL) {
bufsiz = BUFSIZ;
if ((buf = malloc(bufsiz)) == NULL)
return NULL;
}
if (fgets(buf, bufsiz, fp) == NULL)
if (!fp || !len) {
errno = EINVAL;
return NULL;
*len = 0;
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
size_t nbufsiz = bufsiz + BUFSIZ;
char *nbuf = realloc(buf, nbufsiz);
if (nbuf == NULL) {
int oerrno = errno;
free(buf);
errno = oerrno;
buf = NULL;
return NULL;
} else
buf = nbuf;
*len = bufsiz;
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
return buf;
bufsiz = nbufsiz;
}
*len = (ptr - buf) + 1;
return buf;
if (!buf) {
if (!(buf = calloc(1, BUFSIZ)))
return NULL;
bufsz = BUFSIZ;
}
while ((c = getc(fp)) != EOF) {
buf[r++] = c;
if (r == bufsz) {
if (!(p = reallocarray(buf, 2, bufsz))) {
e = errno;
free(buf);
errno = e;
buf = NULL, bufsz = 0;
return NULL;
}
buf = p, bufsz = 2 * bufsz;
}
if (c == '\n')
break;
}
return (*len = r) ? buf : NULL;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,6 +1,6 @@
/*
* Copyright (c) 2010 Dagobert Michelsen
* Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above

View file

@ -1,7 +1,8 @@
# configure.ac
AC_INIT(tmate, 2.2.0)
AC_INIT(tmate, 2.4.0)
AM_SILENT_RULES([yes])
AC_CONFIG_AUX_DIR(etc)
AM_INIT_AUTOMAKE([foreign subdir-objects])
@ -47,8 +48,21 @@ AC_ARG_ENABLE(
found_static=$enable_static
)
if test "x$found_static" = xyes; then
LDFLAGS="$LDFLAGS -static"
# XXX Static build are only doable with the musl library
PKG_CONFIG="pkg-config --static"
CFLAGS="$CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto -static -no-pie"
PKG_CHECK_MODULES([ZLIB], [zlib], [
CPPFLAGS="$ZLIB_CFLAGS $CPPFLAGS"
LIBS="$ZLIB_LIBS $LIBS"
])
PKG_CHECK_MODULES([LIBCRYPTO], [libcrypto], [
CPPFLAGS="$LIBCRYPTO_CFLAGS $CPPFLAGS"
LIBS="$LIBCRYPTO_LIBS $LIBS"
])
fi
# Is this gcc?
@ -89,6 +103,7 @@ AC_CHECK_HEADERS(
bitstring.h \
curses.h \
dirent.h \
execinfo.h \
fcntl.h \
inttypes.h \
libutil.h \
@ -108,9 +123,13 @@ AC_CHECK_HEADERS(
# Look for library needed for flock.
AC_SEARCH_LIBS(flock, bsd)
# Look for library needed for backtrace
AC_SEARCH_LIBS(backtrace, execinfo)
# Check for some functions that are replaced or omitted.
AC_CHECK_FUNCS(
[ \
backtrace \
dirfd \
flock \
setproctitle \
@ -167,10 +186,17 @@ if test "x$found_curses" = xno; then
fi
# Look for utempter.
AC_CHECK_HEADER(utempter.h, have_utempter=yes, have_utempter=no)
if test "x$have_utempter" = xyes; then
AC_DEFINE(HAVE_UTEMPTER)
LIBS="$LIBS -lutempter"
AC_CHECK_HEADER(utempter.h, found_utempter=yes, found_utempter=no)
if test "x$found_utempter" = xyes; then
AC_SEARCH_LIBS(
utempter_add_record,
utempter,
found_utempter=yes,
found_utempter=no
)
if test "x$found_utempter" = xyes; then
AC_DEFINE(HAVE_UTEMPTER)
fi
fi
PKG_CHECK_MODULES(
@ -189,7 +215,7 @@ fi
PKG_CHECK_MODULES(
LIBSSH,
libssh >= 0.6.0,
libssh >= 0.8.4,
[
CPPFLAGS="$LIBSSH_CFLAGS $CPPFLAGS"
LIBS="$LIBSSH_LIBS $LIBS"
@ -198,7 +224,7 @@ PKG_CHECK_MODULES(
found_libssh=no
)
if test "x$found_libssh" = xno; then
AC_MSG_ERROR("libssh >= 0.6.0 not found")
AC_MSG_ERROR("libssh >= 0.8.4 not found")
fi
# Check for b64_ntop.

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2012 Nicholas Marriott <nicholas.marriott@gmail.com>
* Copyright (c) 2012 George Nachman <tmux@georgester.com>
*
* Permission to use, copy, modify, and distribute this software for any

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2012 Nicholas Marriott <nicholas.marriott@gmail.com>
* Copyright (c) 2012 George Nachman <tmux@georgester.com>
*
* Permission to use, copy, modify, and distribute this software for any

View file

@ -1,7 +1,7 @@
/* $OpenBSD$ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -196,10 +196,10 @@ void
environ_push(struct environ *env)
{
struct environ_entry *envent;
char **vp, *v;
char *v;
for (vp = environ; *vp != NULL; vp++) {
v = xstrdup(*vp);
while (*environ != NULL) {
v = xstrdup(*environ);
v[strcspn(v, "=")] = '\0';
unsetenv(v);

66
example_tmux.conf Normal file
View file

@ -0,0 +1,66 @@
#
# Example .tmux.conf
#
# By Nicholas Marriott. Public domain.
#
# Some tweaks to the status line
set -g status-bg green
set -g status-right "%H:%M"
set -g window-status-current-attr "underscore"
# No bells at all
set -g bell-action none
# Lock after 15 minutes
set -g lock-after-time 1800
# Keep windows around after they exit
set -g remain-on-exit on
# Turn on xterm-keys so that additional function keys get escape sequences
set -g xterm-keys on
# Change the prefix key to C-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Turn the mouse on, but without copy mode dragging
set -g mouse on
unbind -n MouseDrag1Pane
unbind -temacs-copy MouseDrag1Pane
# Some extra key bindings to select higher numbered windows
bind F1 selectw -t:10
bind F2 selectw -t:11
bind F3 selectw -t:12
bind F4 selectw -t:13
bind F5 selectw -t:14
bind F6 selectw -t:15
bind F7 selectw -t:16
bind F8 selectw -t:17
bind F9 selectw -t:18
bind F10 selectw -t:19
bind F11 selectw -t:20
bind F12 selectw -t:21
# Keys to toggle monitoring activity in a window, and synchronize-panes
bind m set monitor-activity
bind y set synchronize-panes\; display 'synchronize-panes #{?synchronize-panes,on,off}'
# Keys to hide and show a window name from the status line
bind '-' set window-status-format '#I'\; set window-status-current-format '#I'
bind '+' set window-status-format '#I:#W#F'\; set window-status-current-format '#I:#W#F'
# Create a single default session
new -d -s0 -nirssi 'exec irssi'
set -t0:0 monitor-activity on
set -t0:0 aggressive-resize on
neww -d -ntodo 'exec emacs ~/TODO'
setw -t0:1 aggressive-resize on
neww -d -nmutt 'exec mutt'
setw -t0:2 aggressive-resize on
neww -d
neww -d
neww -d

View file

@ -1,105 +0,0 @@
# START tmux completion
# This file is in the public domain
# See: http://www.debian-administration.org/articles/317 for how to write more.
# Usage: Put "source bash_completion_tmux.sh" into your .bashrc
_tmux()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=" \
attach-session \
bind-key \
break-pane \
capture-pane \
choose-client \
choose-session \
choose-window \
clear-history \
clock-mode \
command-prompt \
confirm-before \
copy-buffer \
copy-mode \
delete-buffer \
detach-client \
display-message \
display-panes \
down-pane \
find-window \
has-session \
if-shell \
join-pane \
kill-pane \
kill-server \
kill-session \
kill-window \
last-window \
link-window \
list-buffers \
list-clients \
list-commands \
list-keys \
list-panes \
list-sessions \
list-windows \
load-buffer \
lock-client \
lock-server \
lock-session \
move-window \
new-session \
new-window \
next-layout \
next-window \
paste-buffer \
pipe-pane \
previous-layout \
previous-window \
refresh-client \
rename-session \
rename-window \
resize-pane \
respawn-window \
rotate-window \
run-shell \
save-buffer \
select-layout \
select-pane \
select-prompt \
select-window \
send-keys \
send-prefix \
server-info \
set-buffer \
set-environment \
set-option \
set-window-option \
show-buffer \
show-environment \
show-messages \
show-options \
show-window-options \
source-file \
split-window \
start-server \
suspend-client \
swap-pane \
swap-window \
switch-client \
unbind-key \
unlink-window \
up-pane"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}
complete -F _tmux tmux
# END tmux completion

View file

@ -1,42 +0,0 @@
# $Id: h-boetes.conf,v 1.2 2009-10-25 21:45:26 nicm Exp $
#
# From Han Boetes.
set -g default-command zsh
set -g status-right "#(uptime|awk '{print $11}') #(date)"
# Statusbar properties.
set -g display-time 3000
set -g status-bg black
set -g status-fg cyan
set-window-option -g window-status-current-attr bright,reverse
set-window-option -g window-status-current-bg cyan
set-window-option -g window-status-current-fg black
# Use c-t instead of c-b as the prefix
unbind C-b
set -g prefix C-t
bind C-t send-prefix
bind t send-prefix
# Bind function keys.
bind -n F1 select-window -t 1
bind -n F2 select-window -t 2
bind -n F3 select-window -t 3
bind -n F4 select-window -t 4
bind -n F5 select-window -t 5
bind -n F6 select-window -t 6
bind -n F7 select-window -t 7
bind -n F8 select-window -t 8
# All new windows started at startup.
new emacs
neww irssi
neww mutt
neww
neww
neww
neww
neww
select-window -t 1

View file

@ -1,110 +0,0 @@
# $Id: n-marriott.conf,v 1.11 2009-11-24 19:03:59 nicm Exp $
#
# By Nicholas Marriott. Public domain.
# Default global options.
set -g status-bg green
set -g status-right "%H:%M" # %d-%b-%y
set -g bell-action none
set -g lock-after-time 1800
# Default global window options.
setw -g remain-on-exit on
setw -g window-status-current-attr "underscore"
#setw -g xterm-keys on
# Prefix key.
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Keys to switch session.
bind Q switchc -t0
bind W switchc -t1
bind E switchc -t2
# Other key bindings.
bind F1 selectw -t:10
bind F2 selectw -t:11
bind F3 selectw -t:12
bind F4 selectw -t:13
bind F5 selectw -t:14
bind F6 selectw -t:15
bind F7 selectw -t:16
bind F8 selectw -t:17
bind F9 selectw -t:18
bind F10 selectw -t:19
bind F11 selectw -t:20
bind F12 selectw -t:21
bind m setw monitor-activity
bind y setw force-width 81
bind u setw force-width 0
bind -n F1 run-shell 'mpc toggle >/dev/null 2>&1'
bind -n F2 run-shell 'mpc'
bind -n F3 run-shell 'mpc prev >/dev/null 2>&1'
bind -n F4 run-shell 'mpc next >/dev/null 2>&1'
bind -n F5 run-shell 'mpc volume -5 >/dev/null 2>&1'
bind -n F6 run-shell 'mpc volume +5 >/dev/null 2>&1'
# Hide and show window name from status line
bind '-' setw window-status-format '#I'\; setw window-status-current-format '#I'
bind '+' setw window-status-format '#I:#W#F'\; setw window-status-current-format '#I:#W#F'
# First session.
new -d -s0 -nirssi 'exec ssh -t natalya exec sh ~/bin/tmux-start'
setw -t0:0 monitor-activity on
setw -t0:0 aggressive-resize on
set -t0 status-bg green
neww -d -ntodo 'exec emacs ~/TODO'
setw -t0:1 aggressive-resize on
neww -d -ntodo2 'exec emacs ~/TODO2'
setw -t0:2 aggressive-resize on
neww -d -nncmpc 'exec ncmpc -f ~/.ncmpc.conf'
setw -t0:3 aggressive-resize on
neww -d -nmutt 'exec mutt'
setw -t0:4 aggressive-resize on
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
# Second session.
new -d -s1
set -t1 status-bg cyan
linkw -dk -t0 -s0:0
linkw -dk -t1 -s0:1
linkw -dk -t2 -s0:2
linkw -dk -t3 -s0:3
linkw -dk -t4 -s0:4
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d
# Third session.
new -d -s2
set -t2 status-bg yellow
linkw -dk -t0 -s0:0
linkw -dk -t1 -s0:1
linkw -dk -t2 -s0:2
linkw -dk -t3 -s0:3
linkw -dk -t4 -s0:4
neww -d
neww -d
neww -d
neww -d
neww -d
neww -d

View file

@ -1,102 +0,0 @@
# $Id: screen-keys.conf,v 1.7 2010-07-31 11:39:13 nicm Exp $
#
# By Nicholas Marriott. Public domain.
#
# This configuration file binds many of the common GNU screen key bindings to
# appropriate tmux key bindings. Note that for some key bindings there is no
# tmux analogue and also that this set omits binding some commands available in
# tmux but not in screen.
#
# Note this is only a selection of key bindings and they are in addition to the
# normal tmux key bindings. This is intended as an example not as to be used
# as-is.
# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix
# Bind appropriate commands similar to screen.
# lockscreen ^X x
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server
# screen ^C c
unbind ^C
bind ^C new-window
unbind c
bind c new-window
# detach ^D d
unbind ^D
bind ^D detach
# displays *
unbind *
bind * list-clients
# next ^@ ^N sp n
unbind ^@
bind ^@ next-window
unbind ^N
bind ^N next-window
unbind " "
bind " " next-window
unbind n
bind n next-window
# title A
unbind A
bind A command-prompt "rename-window %%"
# other ^A
unbind ^A
bind ^A last-window
# prev ^H ^P p ^?
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind BSpace
bind BSpace previous-window
# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows
# quit \
unbind '\'
bind '\' confirm-before "kill-server"
# kill K k
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"
# redisplay ^L l
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client
# split -v |
unbind |
bind | split-window
# :kB: focus up
unbind Tab
bind Tab select-pane -t:.+
unbind BTab
bind BTab select-pane -t:.-
# " windowlist -b
unbind '"'
bind '"' choose-window

View file

@ -1,104 +0,0 @@
# $Id: t-williams.conf,v 1.1 2009-11-02 18:59:28 nicm Exp $
#
# ~/.tmux.conf - tmux terminal multiplexer config
# Thayer Williams (http://cinderwick.ca)
# "Feel free to do whatever you like with it."
# I typically start tmux from ~/.xinitrc with the following:
#
# urxvt -e bash -c "tmux attach -d -t mysession" &
#
# and recall it any time thereafter with xbindkeys (Mod4+s):
#
# "urxvt -e bash -c 'tmux attach -d -t mysession'"
# m:0x50 + c:39
# set prefix key to ctrl+a until I have time to adapt
unbind C-b
set -g prefix C-a
# send the prefix to client inside window (ala nested sessions)
bind-key a send-prefix
# toggle last window like screen
bind-key C-a last-window
# confirm before killing a window or the server
bind-key k confirm kill-window
bind-key K confirm kill-server
# toggle statusbar
bind-key b set-option status
# ctrl+left/right cycles thru windows
bind-key -n C-right next
bind-key -n C-left prev
# open a man page in new window
bind / command-prompt "split-window 'exec man %%'"
# quick view of processes
bind '~' split-window "exec htop"
# scrollback buffer n lines
set -g history-limit 5000
# listen for activity on all windows
set -g bell-action any
# on-screen time for display-panes in ms
set -g display-panes-time 2000
# start window indexing at one instead of zero
set -g base-index 1
# enable wm window titles
set -g set-titles on
# wm window title string (uses statusbar variables)
set -g set-titles-string "tmux.#I.#W"
# session initialization
new -s mysession mutt
neww -t 2
neww -d -t 3
neww -d -t 5 mocp
neww -d -t 6 rtorrent
selectw -t 1
# statusbar --------------------------------------------------------------
set -g display-time 2000
# default statusbar colors
set -g status-fg white
set -g status-bg default
set -g status-attr default
# default window title colors
set-window-option -g window-status-fg cyan
set-window-option -g window-status-bg default
set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr bright
# command/message line colors
set -g message-fg white
set -g message-bg black
set -g message-attr bright
# center align the window list
set -g status-justify centre
# show some useful stats but only when tmux is started
# outside of Xorg, otherwise dwm statusbar shows these already
set -g status-right ""
set -g status-left ""
if '[ -z "$DISPLAY" ]' 'set -g status-left "[#[fg=green] #H #[default]]"'
if '[ -z "$DISPLAY" ]' 'set -g status-right "[ #[fg=magenta]#(cat /proc/loadavg | cut -d \" \" -f 1,2,3)#[default] ][ #[fg=cyan,bright]%a %Y-%m-%d %H:%M #[default]]"'
if '[ -z "$DISPLAY" ]' 'set -g status-right-length 50'

Some files were not shown because too many files have changed in this diff Show more