Commit Graph

204 Commits (22e9cf04cafeb18c88ef1232d63dff5b5173abac)

Author SHA1 Message Date
nicm a81685bfac Add static in cmd-* and fix a few other nits. 2016-10-10 21:51:39 +00:00
Thomas Adam f68a908c8a Merge branch 'obsd-master' 2016-09-04 20:01:16 +01:00
nicm fed1e384ad Add support for performing a full width split (with splitw -f), rather
than splitting the current cell. From Stephen Kent.
2016-09-04 17:37:06 +00:00
Thomas Adam cc096ae929 Merge branch 'obsd-master' 2016-06-06 10:01:11 +01:00
nicm 00cf5fbde6 Insert new panes after the pane being split in the list rather than
always after the active pane. This is more sensible when doing it with
commands rather than keys.
2016-06-06 07:24:31 +00:00
Thomas Adam dc42c35f1f Merge branch 'obsd-master' 2016-01-19 18:01:15 +00:00
nicm 995af0e2b7 I no longer use my SourceForge address so replace it. 2016-01-19 15:59:12 +00:00
Thomas Adam bc6137f9e4 Merge branch 'obsd-master' 2015-12-14 01:30:15 +00:00
nicm a3129fd4e8 Instead of combined flags for -c, -s, -t, split into different sets
using an enum and simplify the parsing code.
2015-12-14 00:31:54 +00:00
Thomas Adam 5caec3020d Merge branch 'obsd-master' 2015-12-13 23:46:58 +00:00
nicm ecfeee2e82 Use member names in cmd_entry definitions so I stop getting confused
about the order.
2015-12-13 21:53:57 +00:00
Thomas Adam ae5ddfdc1a Merge branch 'obsd-master' 2015-12-13 16:01:13 +00:00
nicm 4a4daf1303 Instead of every command resolving the target (-t or -s) itself, prepare
the state (client, session, winlink, pane) for it it before entering the
command. Each command provides some flags that tell the prepare step
what it is expecting.

This is a requirement for having hooks on commands (for example, if you
hook "select-window -t1:2", the hook command should to operate on window
1:2 not whatever it thinks is the current window), and should allow some
other target improvements.

The old cmd_find_* functions remain for the moment but that layer will
be dropped later.

Joint work with Thomas Adam.
2015-12-13 14:32:38 +00:00
Thomas Adam 4909a70174 Merge branch 'obsd-master' 2015-12-11 13:24:45 +00:00
nicm 01831da5f5 Add cmdq as an argument to format_create and add a format for the
command name (will also be used for more later).
2015-12-11 12:27:36 +00:00
Thomas Adam af8134a6ff Merge branch 'obsd-master' 2015-12-08 10:01:16 +00:00
nicm e0f26dcda3 Remove format_create_flags and just pass flags to format_create. 2015-12-08 08:34:18 +00:00
Thomas Adam c975de2e07 Merge branch 'obsd-master'
Conflicts:
	server.c
2015-10-31 23:56:35 +00:00
nicm ba7fb49fb9 Fall back silently to ~ or / rather than checking -c with access(), this
was the old behaviour.
2015-10-31 14:51:15 +00:00
Thomas Adam 17f6c3be8e Merge branch 'obsd-master' 2015-10-31 10:01:12 +00:00
nicm 01defc9f49 Because pledge(2) does not allow us to pass directory file descriptors
around, we can't use file descriptors for the working directory because
we will be unable to pass it to a privileged process to tell it where to
read or write files or spawn children. So move tmux back to using
strings for the current working directory. We try to check it exists
with access() when it is set but ultimately fall back to ~ if it fails
at time of use (or / if that fails too).
2015-10-31 08:13:58 +00:00
Thomas Adam a5e4d3a2d8 Merge branch 'obsd-master' 2015-10-28 12:01:11 +00:00
nicm bf9c933cae Like options, move the environ struct into environ.c. 2015-10-28 09:51:55 +00:00
Thomas Adam da1f6fc2c8 Merge branch 'obsd-master'
Conflicts:
	Makefile
	client.c
	server-client.c
	server.c
	tmux.c
	tmux.h
2015-10-27 23:27:26 +00:00
nicm 44657bf932 Move struct options into options.c. 2015-10-27 15:58:42 +00:00
Thomas Adam 4acc8d0ff5 Merge branch 'obsd-master'
Conflicts:
	cmd-find.c
2015-10-25 09:21:37 +00:00
nicm 26a55ddcf9 Remove some unnecessary checks before free(). 2015-10-23 16:30:15 +00:00
Thomas Adam 94a8ef1cae Merge branch 'obsd-master'
Conflicts:
	Makefile
	tmux.1
2015-04-27 21:21:55 +01:00
nicm 5bd5c9c84e Remove panes from layout if spawning them fails, reported by Anthony J
Bentley.
2015-04-26 20:25:20 +00:00
Thomas Adam 833fe5bdee Merge branch 'obsd-master'
Conflicts:
	cmd-pipe-pane.c
2015-02-06 19:07:43 +00:00
nicm f1e68bfdd2 Remove a couple of now-unused variables. 2015-02-05 10:32:39 +00:00
nicm 4946f74253 Wrap all the individual format_* calls in a single format_defaults
functions.
2015-02-05 10:29:43 +00:00
Thomas Adam 3e8efcc555 Merge branch 'obsd-master' 2014-11-19 09:22:03 +00:00
nicm d37f266524 Add -b to splitw like joinw, from Felix Rosencrantz. 2014-11-12 22:57:06 +00:00
Nicholas Marriott 747cab4281 No need for $Id$ now. 2014-11-08 12:27:43 +00:00
Thomas Adam 562af864bd Merge branch 'obsd-master'
Conflicts:
	Makefile
	cmd-list-commands.c
	cmd-suspend-client.c
	job.c
	tmux.h
	xmalloc.c
2014-10-21 07:11:44 +01:00
nicm 4c42381410 Move template defines back into .c files. 2014-10-20 23:35:28 +00:00
nicm 45dfc5a074 Instead of setting up the default keys by building the key struct
directly with a helper function in the cmd_entry, include a table of
bind-key commands and pass them through the command parser and a
temporary cmd_q.

As well as being smaller, this will allow default bindings to be command
sequences which will probably be needed soon.
2014-10-20 22:29:25 +00:00
Thomas Adam 2874a431c0 Merge branch 'obsd-master' 2014-09-25 11:29:54 +01:00
nicm 4e956d545a Various minor style and spacing nits. 2014-09-01 21:50:18 +00:00
Thomas Adam bae95844d7 Merge branch 'obsd-master'
Conflicts:
	format.c
	window.c
2014-05-13 21:58:48 +01:00
nicm b3e8d440ed If multiple arguments are given to new-session, new-window,
split-window, respawn-window or respawn-pane, pass them directly to
execvp() to help avoid quoting problems. One argument still goes to "sh
-c" like before. Requested by many over the years. Patch from J Raynor.
2014-05-13 08:08:32 +00:00
Thomas Adam 953c3ef47a Merge branch 'obsd-master'
Conflicts:
	Makefile
	tmux.1
	window.c
2014-04-23 11:26:11 +01:00
nicm 3e27be353d Set PATH explicitly, either from client or session
environment. Previously it came from the session environment. From J
Raynor.
2014-04-17 13:02:59 +00:00
Thomas d02c4bda3a Merge branch 'obsd-master' 2014-01-20 10:48:12 +00:00
nicm 7aeb4473ad Handle empty current directory more gracefully. 2013-11-22 20:58:36 +00:00
nicm 909e1c1a86 Don't boke when figuring out working directory from configuration file. 2013-10-10 12:28:38 +00:00
nicm 282c5f9644 Alter how tmux handles the working directory to internally use file
descriptors rather than strings.

- Each session still has a current working directory.

- New sessions still get their working directory from the client that
  created them or its attached session if any.

- New windows are created by default in the session working directory.

- The -c flag to new, neww, splitw allows the working directory to be
  overridden.

- The -c flag to attach let's the session working directory be changed.

- The default-path option has been removed.

To get the equivalent to default-path '.', do:

        bind c neww -c $PWD

To get the equivalent of default-path '~', do:

        bind c neww -c ~

This also changes the client identify protocol to be a set of messages rather
than one as well as some other changes that should make it easier to make
backwards-compatible protocol changes in future.
2013-10-10 12:26:34 +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 9e0d7bddc0 Don't boke when figuring out working directory from configuration file. 2013-10-06 21:31:55 +01:00
Nicholas Marriott 4538c269d0 Alter how tmux handles the working directory to internally use file descriptors
rather than strings.

- Each session still has a current working directory.

- New sessions still get their working directory from the client that created
  them or its attached session if any.

- New windows are created by default in the session working directory.

- The -c flag to new, neww, splitw allows the working directory to be
  overridden.

- The -c flag to attach let's the session working directory be changed.

- The default-path option has been removed.

To get the equivalent to default-path '.', do:

        bind c neww -c $PWD

To get the equivalent of default-path '', do:

        bind c neww -c '#{pane_current_path}'

The equivalent of default-path '~' is left as an exercise for the reader.

This also changes the client identify protocol to be a set of messages rather
than one as well as some other changes that should make it easier to make
backwards-compatible protocol changes in future.
2013-10-06 21:02:23 +01:00
Nicholas Marriott 13360ad541 Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code 2013-10-01 23:50:24 +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 d0fa48db1e Restore missing key binding for %, from Chris Johnsen. 2013-10-01 23:27:36 +01:00
Nicholas Marriott a36da3a878 Remove the barely-used and unnecessary command check() function. 2013-08-21 18:01:40 +01:00
Thomas 00af2df102 Merge branch 'obsd-master' 2013-03-25 16:30:37 +00:00
Nicholas Marriott e44bd9f750 Revert the command-prefix change which breaks sequences of commands. 2013-03-25 15:59:57 +00:00
Nicholas Marriott c71844de63 Add resize-pane -Z to temporary zoom the active pane to occupy the full
window or unzoom (restored to the normal layout) if it already zoomed,
bound to C-b z by default. The pane is unzoomed on pretty much any
excuse whatsoever.

We considered making this a new layout but the requirements are quite
different from layouts so decided it is better as a special case. Each
current layout cell is saved, a temporary one-cell layout generated and
all except the active pane set to NULL.

Prompted by suggestions and scripts from several. Thanks to Aaron Jensen
and Thiago Padilha for testing an earlier version.
2013-03-24 09:57:59 +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 c5239c5984 Add resize-pane -Z to temporary zoom the active pane to occupy the full window
or unzoom (restored to the normal layout) if it already zoomed, bound to C-b z
by default. The pane is unzoomed on pretty much any excuse whatsoever.

We considered making this a new layout but the requirements are quite different
from layouts so decided it is better as a special case. Each current layout
cell is saved, a temporary one-cell layout generated and all except the active
pane set to NULL.

Prompted by suggestions and scripts from several. Thanks to Aaron Jensen and
Thiago Padilha for testing an earlier version.
2013-02-24 00:25:03 +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 31407b70e0 Add option command-prefix which is automatically prepended to any command
(apart from a naked default-shell). The default is "exec ".
2013-02-22 14:31:38 +00:00
Thomas Adam 675c6b3773 Merge branch 'obsd-master'
Sync from OpenBSD.
2012-12-31 18:50:37 +00:00
Nicholas Marriott 3a0016a78a Use the CMD_*_USAGE defines consistently, from Thomas Adam. 2012-12-09 23:17:35 +00:00
Tiago Cunha 1c608031b5 Sync OpenBSD patchset 1162:
Use a separate define for each default format template and strip clutter
from the choose-tree defaults.
2012-08-31 09:18:50 +00:00
Nicholas Marriott 73c6785538 Use a separate define for each default format template and strip clutter
from the choose-tree defaults.
2012-08-14 08:51:53 +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
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
Tiago Cunha 5cc4961fd2 Sync OpenBSD patchset 1119:
Switch all of the various choose- and list- commands over to the format
infrastructure, from Thomas Adam.
2012-05-22 21:03:25 +00:00
Nicholas Marriott ebf94bc9cb Switch all of the various choose- and list- commands over to the format
infrastructure, from Thomas Adam.
2012-05-22 11:35:37 +00:00
Tiago Cunha f41efd9d89 Sync OpenBSD patchset 1069:
Add notify hooks for various events, the functions are currently empty
stubs but will be filled in for control mode later. From George Nachman.
2012-03-18 02:22:09 +00:00
Nicholas Marriott 46210344a6 Add notify hooks for various events, the functions are currently empty
stubs but will be filled in for control mode later. From George Nachman.
2012-03-17 22:35:09 +00:00
Tiago Cunha 3307813a07 Sync OpenBSD patchset 1042:
free -> xfree.
2012-03-07 13:40:08 +00:00
Tiago Cunha 3d98adaf91 Sync OpenBSD patchset 1041:
Add -F format to new-window and split-window to use with the -P flag,
from George Nachman.
2012-03-07 13:39:29 +00:00
Nicholas Marriott 18012f5b18 free -> xfree. 2012-03-04 20:52:05 +00:00
Nicholas Marriott 03dca66ae2 Add -F format to new-window and split-window to use with the -P flag,
from George Nachman.
2012-03-04 20:50:53 +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 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 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
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
Tiago Cunha 9ec457575d Sync OpenBSD patchset 979:
Make window_pane_index work the same as window_index, from Ben Boeckel.
2011-11-25 13:30:45 +00:00
Nicholas Marriott 57df442916 Make window_pane_index work the same as window_index, from Ben Boeckel. 2011-11-15 23:19:51 +00:00
Tiago Cunha cb752f9938 Sync OpenBSD patchset 955:
Plug memory leak, from Tiago Cunha.
2011-09-21 16:34:04 +00:00
Nicholas Marriott 423649b2c6 Plug memory leak, from Tiago Cunha. 2011-08-30 09:18:52 +00:00
Tiago Cunha 391f1f08c0 Expand the Id keyword. 2011-07-09 09:42:33 +00:00
Tiago Cunha c7624fd25d Sync OpenBSD patchset 862:
Size on split-window is -l not -s. Doh.
2011-02-15 15:26:54 +00:00
Nicholas Marriott ce91520e12 Size on split-window is -l not -s. Doh. 2011-02-10 12:12:14 +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
Tiago Cunha 66fb24c3a5 Sync OpenBSD patchset 820:
Add a -P option to new-window and split-window to print the new window
or pane index in target form (useful to pass it into other commands).
2011-01-03 23:29:09 +00:00
Nicholas Marriott b6950ed8aa Add a -P option to new-window and split-window to print the new window
or pane index in target form (useful to pass it into other commands).
2011-01-01 01:33:07 +00:00
Tiago Cunha 63e76b555d Sync OpenBSD patchset 730:
Store the current working directory in the session, change the default-path
option to default to empty and make that mean that the stored session CWD is
used.
2010-07-02 02:49:19 +00:00