summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-run-shell.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Allow multiple modes to be open in a pane. A stack of open modes is keptnicm2019-03-121-4/+4
| | | | | | and the previous restored when the top is exited. If a mode that is already on the stack is entered, the existing instance is moved to the top as the active mode rather than being opened new.
* Make the mode used to view command output (a variant of copy mode) usenicm2019-03-081-2/+5
| | | | | its own mode definition struct with a different init function rather than calling special setup functions.
* Tidy changing the mode into window_copy_init_for_output.nicm2019-03-071-5/+3
|
* Memory leaks, from Gang Fan in GitHub issue 1453.nicm2018-08-271-3/+7
|
* Move job struct into job.c.nicm2018-08-231-13/+14
|
* Make server_client_get_cwd used (almost) everywhere we need to work outnicm2018-05-241-11/+3
| | | | | the cwd, and do not fall back to "." as it is pretty useless. GitHub issue 1331.
* Add a missing client-detached hook when the server shuts down, and donicm2018-03-081-2/+2
| | | | | not exit until jobs started from run-shell/if-shell have finished (add a job flags member and a flag to indicate other jobs). GitHub issue 1245.
* Pass flags into cmd_find_from_* to fix prefer-unattached, reported bynicm2017-08-301-2/+2
| | | | Thomas Sattler.
* Rewrite of choose mode, both to simplify and tidy the code and to addnicm2017-05-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | some modern features. Now the common code is in mode-tree.c, which provides an API used by the three modes now separated into window-{buffer,client,tree}.c. Buffer mode shows buffers, client mode clients and tree mode a tree of sessions, windows and panes. Each mode has a common set of key bindings plus a few that are specific to the mode. Other changes are: - each mode has a preview pane: for buffers this is the buffer content (very useful), for others it is a preview of the pane; - items may be sorted in different ways ('O' key); - multiple items may be tagged and an operation applied to all of them (for example, to delete multiple buffers at once); - in tree mode a command may be run on the selected item (session, window, pane) or on tagged items (key ':'); - displayed items may be filtered in tree mode by using a format (this is used to implement find-window) (key 'f'); - the custom format (-F) for the display is no longer available; - shortcut keys change from 0-9, a-z, A-Z which was always a bit weird with keys used for other uses to 0-9, M-a to M-z. Now that the code is simpler, other improvements will come later. Primary key bindings for each mode are documented under the commands in the man page (choose-buffer, choose-client, choose-tree). Parts written by Thomas Adam.
* Get rid of the extra layer of flags and cmd_prepare() and just store thenicm2017-04-221-6/+6
| | | | | | CMD_FIND_* flags in the cmd_entry and call it for the command. Commands with special requirements call it themselves and update the target for hooks to use.
* Make the cmd_find_* functions more obvious when looking for a client,nicm2017-04-211-2/+2
| | | | | rather than having it inside other functions. Should be no change to the way targets are resolved just yet.
* If a #() command doesn't exit, use its most recent line of output (itnicm2017-04-201-3/+3
| | | | | | | must be a full line). Don't let it redraw the status line more than once a second. Requested by someone about 10 years ago...
* Add a helper function for the most common format_create/defaults/expandnicm2017-03-081-10/+4
| | | | pattern.
* Style nits.nicm2017-02-161-5/+1
|
* Add a window or pane id "tag" to each format tree and use it to separatenicm2017-02-031-2/+2
| | | | | | jobs, this means that if the same job is used for different windows or panes (for example in pane-border-format), it will be run separately for each pane.
* Apply the right fix for run -b, used the wrong diff before.nicm2016-11-121-4/+12
|
* Do not crash with run-shell -b and no window pane available, reported bynicm2016-11-111-7/+2
| | | | Sergei Dyshel.
* Mass rename struct cmd_q to struct cmdq_item and related.nicm2016-10-161-17/+17
|
* Rewrite command queue handling. Each client still has a command queue,nicm2016-10-161-16/+14
| | | | | | | | | | | | | | | but there is also now a global command queue. Instead of command queues being dispatched on demand from wherever the command happens to be added, they are now all dispatched from the top level server loop. Command queues may now also include callbacks as well as commands, and items may be inserted after the current command as well as at the end. This all makes command queues significantly more predictable and easier to use, and avoids the complex multiple nested command queues used by source-file, if-shell and friends. A mass rename of struct cmdq to a better name (cmdq_item probably) is coming.
* Only use pane with run-shell if -t is given.nicm2016-10-151-2/+6
|
* Add static in cmd-* and fix a few other nits.nicm2016-10-101-9/+9
|
* Pass file/line to new command for if-shell so that errors appearnicm2016-10-091-2/+2
| | | | sensibly.
* Expand client formats in run-shell.nicm2016-02-121-2/+2
|
* Instead of combined flags for -c, -s, -t, split into different setsnicm2015-12-141-2/+4
| | | | using an enum and simplify the parsing code.
* Use member names in cmd_entry definitions so I stop getting confusednicm2015-12-131-6/+9
| | | | about the order.
* Instead of every command resolving the target (-t or -s) itself, preparenicm2015-12-131-24/+11
| | | | | | | | | | | | | | | | 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.
* Add cmdq as an argument to format_create and add a format for thenicm2015-12-111-2/+2
| | | | command name (will also be used for more later).
* Remove format_create_flags and just pass flags to format_create.nicm2015-12-081-2/+2
|
* Because pledge(2) does not allow us to pass directory file descriptorsnicm2015-10-311-3/+3
| | | | | | | | | 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).
* Rename cmd_q dead flag to a general flags bitmask (will be more flags later).nicm2015-09-161-2/+2
|
* Set working directory for run-shell and if-shell.nicm2015-04-241-4/+13
|
* Wrap all the individual format_* calls in a single format_defaultsnicm2015-02-051-7/+2
| | | | functions.
* Instead of setting up the default keys by building the key structnicm2014-10-201-2/+1
| | | | | | | | | 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.
* Remove the "info" message mechanism, this was only used for about fivenicm2014-04-171-8/+4
| | | | | | mostly useless and annoying messages. Change those commands to silence on success like all the others. Still accept the -q command line flag and "quiet" server option for now.
* Remove the barely-used and unnecessary command check() function.nicm2013-10-101-2/+1
|
* Try to establish client for run-shell and if-shell if no -t.nicm2013-03-251-1/+10
|
* Extend jobs to support writing and use that for copy-pipe instead ofnicm2013-03-251-2/+2
| | | | popen, from Chris Johnsen.
* Fix if-shell and run-shell if there are no sessions. Batted aroundnicm2013-03-251-14/+17
| | | | through several people, finished off by Chris Johnsen.
* Remove previous.nicm2013-03-251-2/+1
|
* Plug small memory leak in run-shell. Don't potentially leak the commandnicm2013-03-251-1/+2
| | | | to run were it to fail.
* Add a command queue to standardize and simplify commands that call othernicm2013-03-241-24/+23
| | | | | | | | | | | | | | | | | | | | | | 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.
* Expand format variables in the run-shell and if-shell shell commands,nicm2013-03-241-4/+15
| | | | from Thiago Padilha.
* evbuffer_readline returns allocated storage, don't leak it.nicm2013-03-221-1/+2
|
* Add functions to allocate and free command contexts rather than doing itnicm2013-03-221-15/+9
| | | | all on the stack.
* Allow cmd-run-shell to accept -t to specify the pane to display thenicm2012-11-271-10/+37
| | | | output, requested by Alexander Tsepkov.
* Make command exec functions return an enum rather than -1/0/1 values andnicm2012-07-111-7/+6
| | | | | | 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.
* xfree is not particularly helpful, remove it. From Thomas Adam.nicm2012-07-101-5/+6
|
* Simplify the way jobs work and drop the persist type, so all jobs arenicm2011-01-261-5/+3
| | | | | | | | | | | | | | | | | 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).
* Clean up and simplify tmux command argument parsing.nicm2011-01-041-10/+9
| | | | | | | | | | | | | | | | | | | 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.
* When changing so that the client passes its stdout and stderr as well asnicm2010-07-241-5/+2
| | | | | | | | | | | | | | | | | | 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.