Commit Graph

58 Commits (01defc9f4965bb174e1d1295754d5a8695683054)

Author SHA1 Message Date
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
nicm bf9c933cae Like options, move the environ struct into environ.c. 2015-10-28 09:51:55 +00:00
nicm 44657bf932 Move struct options into options.c. 2015-10-27 15:58:42 +00:00
nicm 26a55ddcf9 Remove some unnecessary checks before free(). 2015-10-23 16:30:15 +00:00
nicm 5bd5c9c84e Remove panes from layout if spawning them fails, reported by Anthony J
Bentley.
2015-04-26 20:25:20 +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
nicm d37f266524 Add -b to splitw like joinw, from Felix Rosencrantz. 2014-11-12 22:57:06 +00: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
nicm 4e956d545a Various minor style and spacing nits. 2014-09-01 21:50:18 +00: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
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
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 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 3a0016a78a Use the CMD_*_USAGE defines consistently, from Thomas Adam. 2012-12-09 23:17:35 +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
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 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
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
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
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
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
Nicholas Marriott 8332413305 Add some const and fix a warning. 2012-01-20 19:54:07 +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 57df442916 Make window_pane_index work the same as window_index, from Ben Boeckel. 2011-11-15 23:19:51 +00:00
Nicholas Marriott 423649b2c6 Plug memory leak, from Tiago Cunha. 2011-08-30 09:18:52 +00:00
Nicholas Marriott ce91520e12 Size on split-window is -l not -s. Doh. 2011-02-10 12:12:14 +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 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
Nicholas Marriott 07a71fd432 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-06-27 02:56:59 +00:00
Nicholas Marriott 6a45fab608 New command, join-pane, to split and move an existing pane into the space (like
splitw then movep, or the reverse of breakp).
2010-01-07 20:52:18 +00:00
Nicholas Marriott 526bb6f3e9 Use the specified pane for size calculations. Doh. 2010-01-07 20:02:01 +00:00
Nicholas Marriott 462a11301a Change split-window to accept a pane target (it should be split-pane but
renaming the command would be annoying).
2010-01-07 19:47:10 +00:00
Nicholas Marriott 15a64b805e Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...
2009-12-03 22:50:09 +00:00
Nicholas Marriott 58688c48aa When -h and -p are given to split-window, calculate the percentage size using
the width instead of the height.
2009-11-20 19:12:39 +00:00
Nicholas Marriott 76ef8770cd Get rid of the ugly CMD_CHFLAG macro and use a const string (eg "dDU") in the
command entry structs and a couple of functions to check/set the flags.
2009-11-13 19:53:28 +00:00
Nicholas Marriott 6fab9a3e6f Use KEYC_NONE constant instead of 0 on init. 2009-09-21 15:32:06 +00:00
Nicholas Marriott 5c60162e3c Rather than constructing an entire termios struct from ttydefaults.h, just let
forkpty do it and then alter the bits that should be changed after fork. A
little neater and more portable.
2009-09-16 12:35:04 +00:00
Nicholas Marriott 7d5e494716 When using tmux as a login shell, there is currently no way to specify a shell
to be used as a login shell inside tmux, so add a default-shell session option.
This sets the shell invoked as a login shell when the default-command option is
empty.

The default option value is whichever of $SHELL, getpwuid(getuid())'s pw_shell
or /bin/sh is valid first.

Based on a diff from martynas@, changed by me to be a session option rather
than a window option.
2009-09-01 13:09:49 +00:00
Nicholas Marriott f949107a32 Print -l and -p when showing command, pointed out by Tiago Cunha. 2009-08-25 14:53:22 +00:00
Nicholas Marriott 52793e7a3f When creating a new session from the command-line where there is an external
terminal, copy the termios(4) special characters and use them for new windows
created in the new session. Suggested by Theo.
2009-08-13 19:03:59 +00:00