Commit Graph

332 Commits

Author SHA1 Message Date
Thomas Adam 953c3ef47a Merge branch 'obsd-master'
Conflicts:
	Makefile
	tmux.1
	window.c
2014-04-23 11:26:11 +01:00
nicm 14a96df9ee Remove the choose-list command to prepare for some later choose-* work. 2014-04-16 21:02:41 +00:00
nicm 18cb135218 Don't write into buffer if no arguments, reported by Filipe Rosset. 2014-03-31 21:32:31 +00:00
Nicholas Marriott 0bb9d51965 Don't write into buffer if no arguments, reported by Filipe Rosset. 2014-02-26 21:42:59 +00:00
Thomas d02c4bda3a Merge branch 'obsd-master' 2014-01-20 10:48:12 +00:00
nicm 1a0d3cd5d3 Allow attach-session -t to accept a window and pane to select them on
attach. Based on a diff from J Raynor.
2014-01-09 14:20:55 +00:00
nicm c1ccefc62d We accidentally haven't been using $TMUX to work out the session for a
while and in fact it is less useful that using the client ttyname. So
don't bother and don't pass it from the client. If we need it in future
it is in c->environ.
2013-10-10 12:29:35 +00:00
nicm 6ac7abe8f0 Remove now unused cmd_get_default_path. 2013-10-10 12:28:56 +00:00
nicm b822d24b15 Support -c for new-session, based on code from J Raynor. 2013-10-10 12:07:36 +00:00
Nicholas Marriott e9b09faab2 We accidentally haven't been using $TMUX to work out the session for a while
and in fact it is less useful that using the client ttyname. So don't bother
and don't pass it from the client. If we need it in future it is in c->environ.
2013-10-06 22:38:33 +01:00
Nicholas Marriott 5ea6148362 Remove now unused cmd_get_default_path. 2013-10-06 21:35:44 +01:00
Nicholas Marriott 9389cfbec9 Support -c for new-session, based on code from J Raynor. 2013-10-01 23:48:03 +01:00
Nicholas Marriott a36da3a878 Remove the barely-used and unnecessary command check() function. 2013-08-21 18:01:40 +01:00
Thomas Adam 76cb088d16 Merge branch 'obsd-master'
Conflicts:
	tmux.h
2013-05-25 11:48:12 +01:00
Nicholas Marriott 25c430b1cd Reserve space for \0 in cmd_print, from George Nachman. 2013-05-15 15:34:09 +00:00
Nicholas Marriott b5fda7ad2a Spacing, warning nits. 2013-03-25 12:00:30 +00:00
Nicholas Marriott 673eb160d4 Sort includes and fix spaces. 2013-03-25 11:53:54 +00:00
Nicholas Marriott 6fee3e9e4b Rename session idx to session id throughout and add $ prefix to targets
to use it, extended from a diff from George Nachman.
2013-03-25 10:11:45 +00:00
Nicholas Marriott 410a3abbef Add a wait-for command which blocks a client on a named channel until it
is woken up again (with wait-for -S). From Thiago Padilha.
2013-03-25 10:09:05 +00:00
Nicholas Marriott 20636d956d Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.
2013-03-24 09:54:10 +00:00
Nicholas Marriott bb8457b166 Fix error reporting for client commands by adding a flag to
cmd_find_client to tell it whether or not to show errors, sometimes it's
needed and sometimes not.
2013-03-24 09:27:19 +00:00
Nicholas Marriott 2243cfbe75 Need to set clients in context before changing their reference count. 2013-03-22 15:54:29 +00:00
Nicholas Marriott d1e6ce2672 Add functions to allocate and free command contexts rather than doing it
all on the stack.
2013-03-22 15:49:55 +00:00
Nicholas Marriott 51d989f5df Do not crash when calling choose-tree with a command that changes the mode. 2013-03-21 16:22:48 +00:00
Nicholas Marriott f47a063841 Rename session idx to session id throughout and add $ prefix to targets to use
it, extended from a diff from George Nachman.
2013-03-07 10:07:22 +00:00
Nicholas Marriott 7fd4d49d56 Add a wait-for command which blocks a client on a named channel until it is
wokrn up again (with wait-for -S). From Thiago Padilha.
2013-03-06 09:57:26 +00:00
Nicholas Marriott 43d904dbf3 tty.path can be NULL, don't dereference it. From George Nachman. 2013-03-04 09:02:32 +00:00
Nicholas Marriott 3964309c67 Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent commands. This
allows run-shell and if-shell to be synchronous which has been much requested.

Each client has a default command queue and commands are consumed one at a time
from it. A command may suspend execution from the queue by returning
CMD_RETURN_WAIT and then resume it by calling cmd_continue() - for example
run-shell does this from the callback that is fired after the job is freed.

When the command queue becomes empty, command clients are automatically exited
(unless attaching). A callback is also fired - this is used for nested commands
in, for example, if-shell which can block execution of the client's cmdq until
a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the old
curclient/cmdclient distinction - a cmdq is bound to one client (or none if in
the configuration file), this is a command client if c->session is NULL
otherwise an attached client.
2013-02-23 22:25:58 +00:00
Nicholas Marriott 3a2e9d805a Fix error reporting for client commands by adding a flag to cmd_find_client to
tell it whether or not to show errors, sometimes it's needed and sometimes not.
2013-02-22 23:04:53 +00:00
Nicholas Marriott afd5e978cf Need to set clients in context before changing their reference count. 2013-02-20 10:25:15 +00:00
Nicholas Marriott 293e331d69 Add functions to allocate and free command contexts rather than doing it all on
the stack.
2013-02-18 23:20:21 +00:00
Nicholas Marriott 362c460767 Do not crash when calling choose-tree with a command that changes the mode. 2013-02-13 11:01:26 +00:00
Nicholas Marriott f4c815a1d9 Fix constness again, sigh. 2013-02-13 10:41:12 +00:00
Nicholas Marriott 544c80d715 Fix constness of cmd_template_replace. 2013-02-13 10:19:43 +00:00
Thomas Adam a3f4eb7b24 Merge branch 'obsd-master'
Conflicts:
	Makefile
	grid-utf8.c
2013-01-30 15:27:19 +00:00
Nicholas Marriott c2e2107063 Style nits - return (x) not return x. 2013-01-18 02:10:29 +00:00
Thomas Adam 675c6b3773 Merge branch 'obsd-master'
Sync from OpenBSD.
2012-12-31 18:50:37 +00:00
Nicholas Marriott 854e8ae04d Add ^ and $ special command targets to select lowest and highest
numbered windows, from Raghavendra D Prabhu.
2012-12-24 12:38:57 +00:00
Thomas Adam 39631edb98 Merge branch 'obsd-master'
Sync from OpenBSD.
2012-11-27 18:12:04 +00:00
Nicholas Marriott 991bfcf443 Fix session choice so that preferring unattached sessions actually
works, reported by Drew Frank.
2012-11-27 09:20:03 +00:00
Nicholas Marriott 5d60bc7f7c Use pgrp of pty fd not pid of immediate child when recovering current working
directory (like current process). From Marcel Partap.
2012-09-24 14:05:38 +01:00
Nicholas Marriott 42272dfbd5 Use pgrp of pty fd not pid of immediate child when recovering current
working directory (like current process). From Marcel Partap.
2012-09-24 13:05:10 +00:00
Nicholas Marriott 28fd3a3835 add cmd-choose-list to allow arbitrary options to be selected. From
Thomas Adam.
2012-09-04 22:37:29 +01:00
Nicholas Marriott 7263fa36eb add cmd-choose-list to allow arbitrary options to be selected. From
Thomas Adam.
2012-09-03 09:57:57 +00:00
Tiago Cunha 1f5e6e35d5 Sync OpenBSD patchset 1151:
Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-11 19:37:32 +00:00
Tiago Cunha a432fcd306 Sync OpenBSD patchset 1150:
xfree is not particularly helpful, remove it. From Thomas Adam.
2012-07-11 19:34:16 +00:00
Tiago Cunha a10143a2d1 Sync OpenBSD patchset 1146:
Add choose-tree command to show windows and sessions in the same
list. Change choose-window and -session to use the same code. From
Thomas Adam.
2012-07-11 17:13:55 +00:00
Nicholas Marriott ede8312d59 Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-11 07:10:15 +00:00
Nicholas Marriott df912e3540 xfree is not particularly helpful, remove it. From Thomas Adam. 2012-07-10 11:53:01 +00:00
Nicholas Marriott f20c6fe009 Add choose-tree command to show windows and sessions in the same
list. Change choose-window and -session to use the same code. From
Thomas Adam.
2012-07-08 16:04:38 +00:00
Tiago Cunha 2a36a0a067 Sync OpenBSD patchset 1135:
Do not crash when the current session has no window, fixes a bug
reported by Giorgio Lando. Fix from Thomas Adam.
2012-06-18 15:14:48 +00:00
Nicholas Marriott a4a2c68fa9 Do not crash when the current session has no window, fixes a bug
reported by Giorgio Lando. Fix from Thomas Adam.
2012-06-18 09:20:19 +00:00
Tiago Cunha 995c9a50ab Sync OpenBSD patchset 1099:
Do not return a buffer on the stack, mentioned by jsg a while ago.
2012-04-24 16:22:28 +00:00
Tiago Cunha 31cf5314ee Sync OpenBSD patchset 1095:
Fix printing commands with no arguments, from Benjamin Poirier.
2012-04-24 16:18:35 +00:00
Nicholas Marriott 0f9e0d1cfe Do not return a buffer on the stack, mentioned by jsg a while ago. 2012-04-23 22:43:09 +00:00
Nicholas Marriott 5cbca2e70f Fix printing commands with no arguments, from Benjamin Poirier. 2012-04-22 05:24:05 +00:00
Tiago Cunha e4f1fbd008 Sync OpenBSD patchset 1035:
Add move-pane command (like join-pane but allows the same window). Also
-b flag to join-pane and move-pane to place the pane to the left or
above. From George Nachman.
2012-03-03 09:19:40 +00:00
Nicholas Marriott 07ac16807f Add move-pane command (like join-pane but allows the same window). Also
-b flag to join-pane and move-pane to place the pane to the left or
above. From George Nachman.
2012-03-03 08:31:18 +00:00
Tiago Cunha 3e94fa70f9 Sync OpenBSD patchset 1028:
Don't die if fail to get root directory, from Ben Boeckel.
2012-02-15 19:31:35 +00:00
Nicholas Marriott 67949de0a1 Don't die if fail to get root directory, from Ben Boeckel. 2012-02-06 17:29:29 +00:00
Tiago Cunha 0fd0030a2a Adjust function name to the portable version. 2012-02-02 01:57:14 +00:00
Tiago Cunha 4bb01c1768 Sync OpenBSD patchset 1021:
Provide defined ways to set the various default-path possibilities: ~
for home directory, . for server start directory, - for session start
directory and empty for the pane's working directory (the default). All
can also be used as part of a relative path (eg -/foo). Also provide -c
flags to neww and splitw to override default-path setting.

Based on a diff from sthen. ok sthen
2012-02-02 01:55:34 +00:00
Nicholas Marriott 908a22e41c Provide defined ways to set the various default-path possibilities: ~
for home directory, . for server start directory, - for session start
directory and empty for the pane's working directory (the default). All
can also be used as part of a relative path (eg -/foo). Also provide -c
flags to neww and splitw to override default-path setting.

Based on a diff from sthen. ok sthen
2012-01-31 15:52:21 +00:00
Tiago Cunha 2ee0d851d9 Sync OpenBSD patchset 1017:
Give each window a unique id, like panes but prefixed with @. Based on
work from George Nachman.
2012-01-31 12:01:43 +00:00
Nicholas Marriott 0e59bc75fd Give each window a unique id, like panes but prefixed with @. Based on
work from George Nachman.
2012-01-30 09:39:34 +00:00
Tiago Cunha 5434a2759a Sync OpenBSD patchset 1002:
Add some const and fix a warning.
2012-01-20 21:21:32 +00:00
Nicholas Marriott 8332413305 Add some const and fix a warning. 2012-01-20 19:54:07 +00:00
Tiago Cunha e2d59a6c17 Sync OpenBSD patchset 993:
Allow $HOME as default-path in tmux.conf so the same config file can be used
on different machines regardless of where the user's home directory is.
ok nicm
2011-12-30 14:21:02 +00:00
Stefan Sperling fdd1d0b72e Allow $HOME as default-path in tmux.conf so the same config file can be used
on different machines regardless of where the user's home directory is.
ok nicm
2011-12-27 14:07:20 +00:00
Nicholas Marriott c1b9948525 Change the way the working directory for new processes is discovered. If
default-path isn't empty, it is used. Otherwise:

1) If tmux neww is run from the command line, the working directory of the
client is used.

2) Otherwise use some platform specific code to retrieve the current working
directory of the process in the active pane.

3) If that fails, the directory where the session was created is used.

Idea and support code, Linux, Solaris, FreeBSD bits by Romain Francoise,
OpenBSD bits by me.
2011-12-09 16:37:29 +00:00
Nicholas Marriott f308ba93aa Change the way the working directory for new processes is discovered. If
default-path isn't empty, it is used. Otherwise:

1) If tmux neww is run from the command line, the working directory of the
   client is used.

2) Otherwise sysctl KERN_PROC_CWD is used to retrieve the current
   working directory of the process in the active pane.

3) If that fails, the directory where the session was created is used.

Support code by Romain Francois, OpenBSD specific bits by me.

Note this requires a recent userland and kernel with KERN_PROC_CWD.
2011-12-09 16:28:18 +00:00
Nicholas Marriott f513898e92 PatchSet 924
Date: 2011/06/05 12:19:03
Author: nicm
Branch: HEAD
Tag: (none)
Log:
Add a respawn-pane command, from Marcel Partap.
2011-06-23 19:23:12 +00:00
Nicholas Marriott fa0f10d77a PatchSet 923
Date: 2011/06/05 11:53:05
Author: nicm
Branch: HEAD
Tag: (none)
Log:
Get rid of the layout string code which tries to walk through the layout
hierarchy and instead just look at what panes are actually in the window.
2011-06-23 19:21:26 +00:00
Nicholas Marriott 65177b82be Add a respawn-pane command, from Marcel Partap. 2011-06-05 11:19:03 +00:00
Nicholas Marriott 2b60c648c4 Get rid of the layout string code which tries to walk through the layout
hierarchy and instead just look at what panes are actually in the window.
2011-06-05 10:53:05 +00:00
Tiago Cunha 1d2b487c84 Sync OpenBSD patchset 906:
Fix a memory leak if cmd_pane_session succeeds, from Tiago Cunha.
2011-05-18 20:30:36 +00:00
Nicholas Marriott 6f08472049 Fix a memory leak if cmd_pane_session succeeds, from Tiago Cunha. 2011-05-08 20:35:58 +00:00
Nicholas Marriott e5f4bf3f3e |PatchSet 884
|Date: 2011/04/06 22:51:31
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|Change so that an empty session name always means the current sessions
|even if given with, for example, -t '', and explicitly forbid empty
|session names and those containing a : when they are created.
2011-04-06 22:29:26 +00:00
Nicholas Marriott 4e452a2e11 |PatchSet 882
|Date: 2011/04/05 20:37:01
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|Add a flag to cmd_find_session so that attach-session can prefer
|unattached sessions when choosing the most recently used (if -t is not
|given). Suggested by claudio@.
2011-04-06 22:24:01 +00:00
Nicholas Marriott 536fc24653 PatchSet 870
Date: 2011/03/27 21:27:26
Author: nicm
Branch: HEAD
Tag: (none)
Log:
Give each pane created in a tmux server a unique id (starting from 0),
put it in the TMUX_PANE environment variable and accept it as a
target. Suggested by and with testing and tweaks from Ben Boeckel.
2011-04-06 22:16:33 +00:00
Nicholas Marriott ec89eb9552 Change so that an empty session name always means the current sessions
even if given with, for example, -t '', and explicitly forbid empty
session names and those containing a : when they are created.
2011-04-06 21:51:31 +00:00
Nicholas Marriott 5d519ba526 Add a flag to cmd_find_session so that attach-session can prefer
unattached sessions when choosing the most recently used (if -t is not
given). Suggested by claudio@.
2011-04-05 19:37:01 +00:00
Nicholas Marriott 808502ac3d Give each pane created in a tmux server a unique id (starting from 0),
put it in the TMUX_PANE environment variable and accept it as a
target. Suggested by and with testing and tweaks from Ben Boeckel.
2011-03-27 20:27:26 +00:00
Tiago Cunha d0d1c0e486 Sync OpenBSD patchset 848:
Set $TMUX without the session when background jobs are run.
2011-02-14 23:11:33 +00:00
Nicholas Marriott b8023044c3 Set $TMUX without the session when background jobs are run. 2011-01-23 11:03:43 +00:00
Tiago Cunha 1df427bc7b Sync OpenBSD patchset 829:
Clean up and simplify tmux command argument parsing.

Originally, tmux commands were parsed in the client process into a
struct with the command data which was then serialised and sent to the
server to be executed. The parsing was later moved into the server (an
argv was sent from the client), but the parse step and intermediate
struct was kept.

This change removes that struct and the separate parse step. Argument
parsing and printing is now common to all commands (in arguments.c) with
each command left with just an optional check function (to validate the
arguments at parse time), the exec function and a function to set up any
key bindings (renamed from the old init function).

This is overall more simple and consistent.

There should be no changes to any commands behaviour or syntax although
as this touches every command please watch for any unexpected changes.
2011-01-07 14:45:34 +00:00
Nicholas Marriott 7502cb3adb Clean up and simplify tmux command argument parsing.
Originally, tmux commands were parsed in the client process into a
struct with the command data which was then serialised and sent to the
server to be executed. The parsing was later moved into the server (an
argv was sent from the client), but the parse step and intermediate
struct was kept.

This change removes that struct and the separate parse step. Argument
parsing and printing is now common to all commands (in arguments.c) with
each command left with just an optional check function (to validate the
arguments at parse time), the exec function and a function to set up any
key bindings (renamed from the old init function).

This is overall more simple and consistent.

There should be no changes to any commands behaviour or syntax although
as this touches every command please watch for any unexpected changes.
2011-01-04 00:42:46 +00:00
Nicholas Marriott cc42614fa9 Change from a per-session stack of buffers to one global stack which is
much more convenient and also simplifies lot of code. This renders
copy-buffer useless and makes buffer-limit now a server option.

By Tiago Cunha.
2010-12-30 23:16:18 +00:00
Tiago Cunha 9ebee6aef8 Global paste buffers instead of per-session which renders copy-buffer useless.
As a consequence buffer-limit is now a server option.
2010-12-30 22:39:49 +00:00
Tiago Cunha a373235106 Sync OpenBSD patchset 806:
Store sessions in an RB tree by name rather than a list, this is tidier
and allows them to easily be shown sorted in various lists
(list-sessions/choose-sessions).

Keep a session index which is used in a couple of places internally but
make it an ever-increasing number rather than filling in gaps with new
sessions.
2010-12-22 15:36:44 +00:00
Nicholas Marriott acf13ce978 Store sessions in an RB tree by name rather than a list, this is tidier
and allows them to easily be shown sorted in various lists
(list-sessions/choose-sessions).

Keep a session index which is used in a couple of places internally but
make it an ever-increasing number rather than filling in gaps with new
sessions.
2010-12-21 22:37:59 +00:00
Nicholas Marriott 39e277be3c |---------------------
|PatchSet 781
|Date: 2010/10/29 21:11:57
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|We now send argv to the server after parsing it in the client to get the
|command, so the client should not modify it. Instead, take a copy. Fixes
|parsing command lists, reported by mcbride@.
|
|Members:
|       cmd-list.c:1.5->1.6
|       cmd.c:1.45->1.46
|       tmux.h:1.244->1.245
2010-12-06 21:48:56 +00:00
Nicholas Marriott 34d05ea7cd We now send argv to the server after parsing it in the client to get the
command, so the client should not modify it. Instead, take a copy. Fixes
parsing command lists, reported by mcbride@.
2010-10-29 20:11:57 +00:00
Tiago Cunha cd079e8fbf Sync OpenBSD patchset 780:
Add a last-pane command (bound to ; by default). Requested ages ago by
somebody whose name I have forgotten.
2010-10-24 01:34:30 +00:00
Tiago Cunha 5a0ecc5931 Sync OpenBSD patchset 774:
Fall back on normal session choice method if $TMUX exists but is invalid
rather than rejecting.
2010-10-24 00:32:35 +00:00
Nicholas Marriott 5de84eca3d Add a last-pane command (bound to ; by default). Requested ages ago by
somebody whose name I have forgotten.
2010-10-23 13:04:34 +00:00
Nicholas Marriott 6c42f1a89e Fall back on normal session choice method if $TMUX exists but is invalid
rather than rejecting.
2010-10-16 07:57:42 +00:00
Tiago Cunha 11f81e8134 Sync OpenBSD patchset 735:
Make pane/window wrapping more logical (so with 10 windows, +10 from
window 5 stays in the same place), and tidy the code. From Tiago Cunha.
2010-07-17 14:38:13 +00:00
Nicholas Marriott 43355fa75c Make pane/window wrapping more logical (so with 10 windows, +10 from
window 5 stays in the same place), and tidy the code. From Tiago Cunha.
2010-07-14 18:37:49 +00:00
Tiago Cunha bf1e237410 Sync OpenBSD patchset 726:
Add a choose-buffer command for easier use of the paste buffer stack.
2010-06-22 23:35:20 +00:00