certain C0 sequences (linefeeds, backspaces, carriage returns) and if it
exceeds a threshold (current default 50/millisecond), start to redraw
the pane every 100 milliseconds instead of making each change as it
comes. Two configuration options - c0-change-trigger and
c0-change-interval.
This makes tmux much more responsive under very fast output (for example
yes(1) or accidentally cat'ing a large file) but may not be perfect on
all terminals and connections - feedback very welcome, particularly
where this change has a negative rather than positive effect (making it
off by default is a possibility).
After much experimentation based originally on a request Robin Lee
Powell (which ended with a completely different solution), this idea
from discussion with Ailin Nemui.
this is used and the application has requested bracketed pastes, then
tmux surrounds the pasted text by \033[200~ and \033[201~. Applications
like vim can (apparently) use this to avoid, for example, indenting the
text. From Ailin Nemui.
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
separate options, prefix and prefix2. This simplifies the code and gets
rid the data options type which was only used for this one option.
Also add a -2 flag to send-prefix to send the secondary prefix key,
fixing a cause of minor irritation.
People who want three prefix keys are out of luck :-).
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.
use it for list-{panes,windows,sessions}. This allows more descriptive
replacements (such as #{session_name}) and conditionals.
Later this will be used for status_replace and list-keys and other
places.
the xterm escape sequence for the purpose (if xterm is configured to
allow it).
Written by and much discussed Ailin Nemui, guidance on
xterm/termcap/terminfo from Thomas Dickey.
mode when the mouse is dragged or the mouse wheel is used. Also exit
copy mode when the mouse wheel is scrolled off the bottom. Discussed
with and written by hsim at gmx dot li.
using DCS with a "tmux;" prefix. Escape characters in the sequences must
be doubled. For example:
$ printf '\033Ptmux;\033\033]12;red\007\033\\'
Will pass \033]12;red\007 to the terminal (and change the cursor colour
in xterm). From Kevin Goodsell.
fire-and-forget.
Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.
This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).
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.
and supports larger terminals than the older way.
If the new mouse-utf8 option is on, UTF-8 mouse input is enabled for all
UTF-8 terminals. The option defaults to on if LANG etc are set in the
same manner as the utf8 option.
With help and based on code from hsim at gmx.li.
values) together into one set of tables in options-table.c. Also clean
up and simplify cmd-set-options.c and move a common print function into
option-table.c.
this screws up the choice of most-recently-used. Instead, break the time
update into a little function and do it when the session is attached.
Pointed out by joshe@.
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.
be and I can't find it, but the flag itself is a useless optimisation
that only applies to automatic-resize windows, so just dispose of it
entirely.
Fixes problems reported by Nicholas Riley.
- server option "exit-unattached" makes the server exit when no clients
are attached, even if sessions are present;
- session option "destroy-unattached" destroys a session once no clients
are attached to it.
These are useful for preventing tmux remaining in the background where
it is undesirable and when using tmux as a login shell to keep a limit
on new sessions.
terminals (I'm looking at you, putty) which disable the vt100 ACS mode
switching sequences in UTF-8 mode.
Also on terminals without ACS at all, use ASCII equivalents where
obvious.
when the client tty backs up too much, just stop updating the tty and
only update the internal screen. Then when the tty recovers, force a
redraw.
This prevents a dodgy client from causing other clients to go into
backoff while still allowing tmux to be responsive (locally) when seeing
lots of output.
stdin up to the server, I forgot one essential point - the tmux server
could now be both the producer and consumer. This happens when tmux is
run inside tmux, as well as when piping tmux commands together.
So, using stdio(3) was a bad idea - if sufficient data was written, this
could block in write(2). When that happened and the server was both
producer and consumer, it deadlocks.
Change to use libevent bufferevents for the client stdin, stdout and
stderr instead. This is trivial enough for output but requires a
callback mechanism to trigger when stdin is finished.
This relies on the underlying polling mechanism for libevent to work
with whatever devices to which the user could redirect stdin, stdout or
stderr, hence the change to use poll(2) over kqueue(2) for tmux.
commands can directly make use of them. This means that load-buffer and
save-buffer can have "-" as the file to read from stdin or write to stdout.
This is a protocol version bump so the tmux server will need to be restarted
after upgrade (or an older client used).
after the command is executing is bogus because it may still be needed if the
same command is going to be executed again (for example if you "bind-key a
bind-key b ..."). Making a copy is hard, so instead add a reference count to
the cmd_list.
While here, also print bind-key -n and the rest of the flags properly.
Fixes problem reported by mcbride@.
starting tmux from .xinitrc.
One of the very few things the server relies on the client for now is to
pass through a message on SIGWINCH, but there is a condition where
potentially a SIGWINCH may be lost during the transition from unattached
(main.c) to attached (client.c). So trigger a size change immediately
after the client installs its SIGWINCH handler.
Also, when the terminal is resized, reset the scroll region and cursor
position. Previously, we were clearing our saved idea of these, but in
fact some terminals do not reset them on resize, so this caused problems
during redraw.
While here make a resize to the same size not cause a redraw and rename
the tmux.out output log file to include the tmux PID.
in copy mode.
Also support the scroll wheel, although xterm strangely does not ignore
it in application mouse mode, causing redraw artifacts when scrolling up
(other terminals appear to be better behaved).
function. We were only ever using the client to find the session anyway.
This allows send-key to work properly for manipulating copy mode from
outside tmux.
From Micah Cowan.
window. Set and displayed with "set -s" and "show -s".
Currently the only option is "quiet" (like command-line -q, allowing it to be
set from .tmux.conf), but others will come along.
a -w flag to set-option and show-options and making setw and showw aliases to
set -w and show -w.
Note: setw and showw are still there, but now aliases for set -w and show -w.
allow the format of each window in the status line window list to be controlled
using similar # sequences as status-left/right.
This diff also moves part of the way towards UTF-8 support in window names but
it isn't quite there yet.
exists. A new message-limit session option sets the maximum number of entries
and a command, show-messages, shows the log (bound to ~ by default).
This (and prompt history) might be better as a single global log but until
there are global options it is easier for them to be per client.
partial matches to be done (they wait for further data or a timer to expire,
like a naked escape).
Mouse and xterm-style keys still expect to be atomic.
complicated because of escape input, but in that case instead of processing a
key immediately, schedule a timer and reprocess the bufer when it expires.
This currently assumes that keys will be atomic (ie that if eg F1 is pressed
the entire sequence is present in the buffer). This is usually but not always
true, a change in the tree format so it can differentiate potential (partial)
key sequences will happens soon and will allow this to be fixed.
This moves the client-side loops are pretty much fully over to event-based only
(tmux.c and client.c) but server-side (server.c and friends) treats libevent as
a sort of clever poll, waking up after every event to run various things.
Moving the server stuff over to bufferevents and timers and so on will come
later.
client lookup to pick the most recently used rather than the most recently
created - this is much more useful when used interactively and (because the
activity time is set at creation) should have no effect on source-file.
Based on a problem reported by Jan Johansson.
meaningful names.
Also, remove the code to try and update the session activity time for the
command client when a command message is received as is pointless because it
des not have a session.
status jobs, then only kill those jobs when status-left, status-right or
set-titles-string is changed.
Fixes problems with changing options from inside #().
buffered, don't accept any further data from the process running in the pane.
This makes tmux much more responsive when flooded with output, although other
buffers can still have an impact when running remotely.
Prompted by a query from Ranganathan Sankaralingam.
Irritatingly, although op can be used to tell if a terminal supports default
colours, it can't be used to set them because in some terminfo descriptions it
resets attributes as a side-effect (acts as sgr0) and in others it doesn't, so
it is not possible to determine reliably what the terminal state will be
afterwards. So if AX is missing and op is present, tmux just sends sgr0.
Anyone using -d for a terminal who finds they actually needed it can replace it
using terminal-overrides, but please let me know as it is probably an omission
from terminfo.
files from server.c (merging server-msg.c into the client file) and rather than
iterating over each set after poll(), allow a callback to be specified when the
fd is added and just walk once over the returned pollfds calling each callback
where needed.
More to come, getting this in so it is tested.
Get rid of passing around u_char[4]s and define a struct utf8_data which has
character data, size (sequence length) and width. Move UTF-8 character
collection into two functions utf8_open/utf8_append in utf8.c which fill in
this struct and use these functions from input.c and the various functions in
screen-write.c.
Space for rather more data than is necessary for one UTF-8 sequence is in the
utf8_data struct because screen_write_copy is still nasty and needs to reinject
the character (after combining) into screen_write_cell.
Thai can have treble combinations (1 x width=1 then 2 x width=0) so bump the
UTF-8 cell data size to 9 and alter the code to allow this.
Also break off the combining code into a separate function, handle any further
combining beyond the buffer size by replacing the character with _s, and when
redrawing the UTF-8 character don't assume the first part has just been
printed, redraw the entire line.
permit them to wrap naturally again. This allows terminals that use this to
guess where lines start and end for eg mouse selecting (like xterm) to work
correctly.
This was another long-standing issue raised by several people over the last
while.
Thanks to martynas@ for much testing. This was not trivial to get right so
bringing it in for wider testing and adn to fix any further glitches in-tree.
wrapped, move the cursor back up to the end of the previous line.
Another one of the forgotten persons requested this quite a while ago (I need
to start noting names on todo items...) when it was quite hard to
implement. Now it is easy and I don't see it can do any harm, so hey presto...
example:
pipe-pane 'cat >~/out'
No arguments stops outputing and closes the pipe; the -o flag toggles a pipe
and on and off (useful for key bindings).
Suggested by espie@.
three u_chars around.
As a side-effect this fixes incorrectly rejecting high cursor positions
(because it was comparing them as signed char), reported by Tom Doherty.
immediately every redraw, queue them up and run them in the background,
starting each once every status-interval. The actual status line uses the
output from the last run.
This brings several advantages:
- tmux itself may be called from inside #() without causing the server to hang;
- likewise, sleep or similar doesn't cause the server to block;
- commands aren't run excessively often when redrawing;
- commands shared by status-left and status-right, or used multiple times, will
only be run once.
run-shell and if-shell still use system()/popen() but will be changed over to
use this too later.
so on but where the linked windows are synchronized (ie creating, killing
windows and so on are mirrored between the sessions). A grouped session may be
created by passing -t to new-session.
Had this around for a while, tested by a couple of people.
the lock-server option (it is on by default). When this is off, each session
locks when it has been idle for the lock-after-time setting. When on, the
entire server locks when ALL sessions have been idle for their individual
lock-after-time settings.
This replaces one global-only option (lock-after-time) with another
(lock-server), but the default behaviour is usually preferable so there don't
seem to be many alternatives.
Diff/idea largely from Thomas Adam, tweaked by me.
current client, in a similar manner to how sessions already work: if the
current session can be established and has only one client, use that; otherwise
use the most recently created client.
command specified by a new option "lock-command" (by default "lock -np") in
each client.
This means each terminal has to be unlocked individually but simplifies the
code and allows the system password to be used to unlock.
Note that the set-password command is gone, so it will need to be removed from
configuration files, and the -U command line flag has been removed.
This is the third protocol version change so again it is best to stop the tmux
server before upgrading.
into the server.
This is another (the second of four) protocol version changes coming this
morning, so again the server should be killed before upgrading.
with imsg and fatal if it doesn't, then set the FD_CLOEXEC flag in tty_init
instead of tty_open to prevent them leaking into child processes if any are
created between the two calls.
This bumps the protocol version, so the tmux server should be killed before
upgrading.
use the error and exit on MSG_EXIT (it was being handled in the default
case). Undo the last change, move the errstr check into the MSG_EXIT case, and
add a comment.
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.
template. After a choice is made, %% (or %1) in the template is replaced by the
name of the session, window or client suitable for -t and the result executed
as a command. So, for example, "choose-window "killw -t '%%'"" will kill the
selected window.
The defaults if no template is given are (as now) select-window for
choose-window, switch-client for choose-session, and detach-client for
choose-client (now bound to D).
or more prompts to present in order.
The responses to the prompt are replaced in the template string: %% are
replaced in order, so the first prompt replaces the first %%, the second
replaces the second, and so on. In addition, %1 up to %9 are replaced with the
responses to the first the ninth prompts
The default template is "%1" so the response to the first prompt is processed
as a command.
Note that this changes the behaviour for %% so if there is only one prompt,
only the first %% will be replaced. Templates such as "neww -n '%%' 'ssh %%'"
should be changed to "neww -n '%1' 'ssh %1'".
From Tiago Cunha.
there is unconsumed data, save the previous size and use it instead. This means
that activity monitoring should work in this (unlikely) event.
Also remove a debugging statement that no longer seems necessary.
emacs keys, / and ? with vi; n repeats the search again with either key
set. All searching wraps the top/bottom. Goto line is g for both emacs and vi.
The search prompts don't have full line editing, just simple append and delete
characters.
Also sort the mode keys list in tmux.1.
scroll key to C-b instead of C-u and use C-u/C-d for half page scrolling with
vi keys. In emacs mode, half page scrolling is bound to M-Up and M-Down.
Suggested by merdely (about a year ago :-)).
clients, so make it const.
Also fix an actual modification which caused a hang when a session was
connected to multiple terminals at least one of which was missing ich/ich1.
have the server use that rather than reopening the tty. If the fd isn't given,
use the old behaviour (so no need for a version change).
This allows tmux to be used as the shell, so also change so that when working
out the command to execute if default-command is empty (the default), tmux will
try not execute itself.
client-server protocol more resilient and make the protocol versioning work
properly. In future, the only things requiring a protocol version bump will be
changes in the message structs, and (when both client and server have this
change) mixing different versions should nicely report an error message.
As a side effect this also makes the code tidier, fixes a problem with the way
errors reported during server startup were handled, and supports fd passing
(which will be used in future).
Looked over by eric@, thanks.
Please note that mixing a client with this change with an older server or vice
versa may cause tmux to crash or hang - tmux should be completely exited before
upgrading.
within tmux.
There is a global environment, copied from the external environment when the
server is started and each sesssion has an (initially empty) session
environment which overrides it.
New commands set-environment and show-environment manipulate or display the
environments.
A new session option, update-environment, is a space-separated list of
variables which are updated from the external environment into the session
environment every time a new session is created - the default is DISPLAY.
- a two-dimensional array of cells;
- a two-dimensional array of utf8 data;
- an array of line lengths.
Now it is a single array of a new struct grid_line each of which represents a
line and containts the length and an array of cells and an array of utf8 data.
This will make it easier to add additional per-line members, such as flags.
cause the client to hang. Instead, send the error message, then mark the client
as bad and start a normal shutdown so the server exits once the error is
written.
This also allows some code duplicating daemon(3) to be trimmed and logging to
begin earlier.
Prompted by Theo noticing the behaviour on error wasn't documented.
to be overridden. The 88col/256col checks are now moved into the default
setting and out of the code.
Also remove a couple of old workarounds for xterm and rxvt which are no longer
necessary (tmux can emulate them if missing).
lookup table and use a switch, merge the tiny handler functions into it, and
move the whole lot to client.c.
Also change client_msg_dispatch to consume as many messages as possible and
move the call to it to the right place so it checks for signals afterwards.
Prompted by suggestions from eric@.
using -p index, a target pane is now addressed with the normal -t window form
but suffixed with a period and a pane index, for example :0.2 or
mysess:mywin.1. An unadorned number such as -t 1 is tried as a pane index in
the current window, if that fails the same rules are followed as for a target
window and the current pane in that window used.
As a side-effect this now means that swap-pane can swap panes between different
windows.
Note that this changes the syntax of the break-pane, clear-history, kill-pane,
resize-pane, select-pane and swap-pane commands.
a named tree on start and use that for lookups. Also add command to string
translation tables and modify list-keys to show the the mode key bindings (new
-t argument).
lumping them all together, split editing keys from those used in choice/more
mode and those for copy/scroll mode.
Tidier and clearer, and the first step towards customisable mode keys.
matches screen's behaviour if not its termcap/terminfo entry). The terminfo kbs
cap is often wrong or missing so it can't be used, and just assuming \177 may
be wrong.
This is the first of two changes to make the protocol more resilient and less
sensitive to other changes in the code, particularly with commands. The client
now packs argv into a buffer and sends it to the server for parsing, rather
than doing it itself and sending the parsed command data.
As a side-effect this also removes a lot of now-unused command marshalling
code.
Mixing a server without this change and a client with or vice versa will cause
tmux to hang or crash, please ensure that tmux is entirely killed before
upgrading.
Each window now has a tree of layout cells associated with it. In this tree,
each node is either a horizontal or vertical cell containing a list of other
cells running from left-to-right or top-to-bottom, or a leaf cell which is
associated with a pane.
The major functional changes are:
- panes may now be split arbitrarily both horizontally (splitw -h, C-b %) and
vertically (splitw -v, C-b ");
- panes may be resized both horizontally and vertically (resizep -L/-R/-U/-D,
bound to C-b left/right/up/down and C-b M-left/right/up/down);
- layouts are now applied and then may be modified by resizing or splitting
panes, rather than being fixed and reapplied when the window is resized or
panes are added;
- manual-vertical layout is no longer necessary, and active-only layout is gone
(but may return in future);
- the main-pane layouts now reduce the size of the main pane to fit all panes
if possible.
Thanks to all who tested.
these are enabled (and the monitor-activity, bell-actio and monitor-content
options are configurated appropriately), when activity, a bell, or content is
detected, a message is shown.
Also tidy up the bell/activity/content code in server.c slightly and fix a
couple of errors.
status line (bound to "i" and displays the current window and time by
default). The same substitutions are applied as for status-left/right.
- Add support for including the window index (#I), pane index (#P) and window
name (#W) in the message, and status-left or status-right.
- Bump protocol version.
From Tiago Cunha, thanks!
still present, so add a separate prompt free callback and make the _clear
function responsible for calling it if necessary (rather than the individual
prompt callbacks). Also make both messages and prompts clear any existing when
a new is set.
In addition, the screen could be modified while the prompt is there, restore
the redraw-entire-screen behaviour on prompt clear; add a comment as a
reminder.
annoying and it is only use for iterating, so use a sentinel to mark the end of
each array instead. Different fix for a problem pointed out by Kalle Olavi
Niemitalo.
decision for whether or not a pane should be drawn out of the layout code and
into the redraw code.
This is needed for the new layout design, getting it in now to make that easier
to work on.
maintain and is only going to get worse as more are used. So instead, add a new
uint64_t member to cmd_entry which is a bitmask of upper and lowercase options
accepted by the command.
This means new single character options can be used without the need to add it
explicitly to the list.
- move the code back into cmd.c and merge with the existing functions where
possible;
- accept "-tttyp0" as well as "-t/dev/ttyp0" for clients;
- when looking up session names, try an exact match first, and if that fails
look for it as an fnmatch pattern and then as the start of a name - if more
that one session matches an error is given; so if there is one session called
"mysession", -tmysession, -tmysess, -tmysess* are equivalent but if there
is also "mysession2", the last two are errors;
- similarly for windows, if the argument is not a valid index or exact window
name match, try it against the window names as an fnmatch pattern and a
prefix.
screen interactive programs to preserve the screen contents. When activated, it
saves a copy of the visible grid and disables scrolling into and resizing out
of the history; when deactivated the visible data is restored and the history
reenabled.
and makes emacs happy when pasting into some modes. A new -r (raw) flag to
paste-buffer pastes without the translation.
From Kalle Olavi Niemitalo, thanks!
argument if the shell command in the first succeeds, for example:
if "[ -e ~/.tmux.conf.alt ]" "source .tmux.conf.alt"
Written by Tiago Cunha, many thanks.
and some people may use shells which do not support it. Instead, make an empty
default-command option mean a login shell, and fork it with a - in argv[0]
which is the method used by login(1).
Also fix the automatic-rename code to handle this correctly and to strip a
leading - if present.
compatibility, *s are implicitly added at the start and end of the pattern.
Also display the line number and the entire line in the results, and lose the
nasty section_string function and the now empty util.c file.
Initially from Tiago Cunha.
normal eight-bit output is wrong, separate it into a different function. Fixes
spacing when mixing UTF-8 with some escape sequences, notably the way w3m does
it.
status-left/status-right work properly. At the moment any top-bit-set
characters are assumed to be UTF-8: a status-utf8 option to configure this will
come shortly.
crashes when trying to find the new active pane.
While here, nuke an unused pane flag.
Fixes PR 6160, reported by and a slightly different version of diff tested by
ralf.horstmann at gmx.de.
terminal to be switched between several different windows and programs
displayed on one terminal be detached from one terminal and moved to another.
ok deraadt pirofti