On Fri, Jan 22, 2010 at 04:21:06PM -0500, Sudish Joseph wrote:
> Nicholas Marriott <nicholas.marri...@gmail.com> writes:
> > On Thu, Jan 21, 2010 at 01:33:56AM -0800, Robin Lee Powell wrote:
> >> Why does "tmux new-session vim \; split-window \; attach" not
> >> work? Why does it need the -d, I mean? Seems like attaching a
> >> session shouldn't stop the split-window command from being
> >> proccessed.
> >
> > new-session without -d implies attach and that stops further command
> > processing, although I can't remember why and it probably shouldn't.
>
> That clarified a lot for me and would make a great one-line addition to
> the man page para for new-session.
My man page patch (attached) now mentions this.
> Also, 'tmux new "tmux source ..."' didn't work either, iirc. The
> explicit neww was needed in the 2nd tmux invocation above -- I
> assumed that 'tmux new' doesn't create a new window if passed a
> shell command(?).
It does, actually, but it fills the window with the results of the
command. When the command exits, the window closes. For example:
tmux new-session 'tmux new-window'
you'll notice that you get one window, but the window number is "1".
That's because 'tmux new-window' ran in window zero, did its thing,
and exited.
My man page patch now mentions this (that the window closes when the
shell comand exits), as well.
> This is all much cleaner with 'new -d' -- no subshells or subsequent
> tmux invocations:
>
> tmux new-session -d \; source $conf_file \; attach
My patch also has an example similar to that.
I'd love a second review to the patch, if you're interested.
The patch now also includes the TODO changes Nicholas asked for. :)
-Robin
--
They say: "The first AIs will be built by the military as weapons."
And I'm thinking: "Does it even occur to you to try for something
other than the default outcome?" See http://shrunklink.com/cdiz
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/
Index: TODO
===================================================================
RCS file: /cvsroot/tmux/tmux/TODO,v
retrieving revision 1.442
diff -u -r1.442 TODO
--- TODO 23 Jan 2010 11:07:25 -0000 1.442
+++ TODO 23 Jan 2010 20:37:13 -0000
@@ -1,3 +1,9 @@
+- select-prompt does the same as: command-prompt -pindex
+ "select-window -t '%%'" (Or what it would do if I hadn't somehow
+ broken it in HEAD.) So it could probably be removed.
+- new-session without -d implies attach and that stops further
+ command processing, although I can't remember why and it probably
+ shouldn't.
- window creation/idle time
- better errors when creating new windows/sessions (how?)
- implicitly add exec to the commands for new windows (switch to disable it)?
Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.222
diff -u -r1.222 tmux.1
--- tmux.1 22 Jan 2010 17:28:34 -0000 1.222
+++ tmux.1 23 Jan 2010 20:37:14 -0000
@@ -111,6 +111,8 @@
server will be started to retrieve the
.Ic default-shell
option.
+This is used when tmux is set as the login shell, since external
+tools expect -c to work with any shell.
.It Fl f Ar file
Specify an alternative configuration file.
By default,
@@ -342,6 +344,40 @@
.Em bottom-right
may be used instead of a pane index.
.Pp
+.Ar shell-command
+arguments are
+.Xr sh 1
+commands.
+These must be passed as a single item, which typically means quoting them, for
+example:
+.Bd -literal -offset indent
+new-window 'vi /etc/passwd'
+.Ed
+.Pp
+When the shell command completes, the window closes. See
+the
+.Ic remain-on-exit
+option and the
+.Ic respawn-window
+command for how do use non-interactive or otherwise exiting shell
+commands under tmux.
+.Pp
+.Ar command
+.Op Ar arguments
+refers to a
+.Nm
+command, passed with the command and arguments separately, for example:
+.Bd -literal -offset indent
+bind-key F1 set-window-option force-width 81
+.Ed
+.Pp
+Or if using
+.Xr sh 1 :
+.Pp
+.Bd -literal -offset indent
+$ tmux bind-key F1 set-window-option force-width 81
+.Ed
+.Pp
Multiple commands may be specified together as part of a
.Em command sequence .
Each command should be separated by spaces and a semicolon;
@@ -349,8 +385,10 @@
A literal semicolon may be included by escaping it with a backslash (for
example, when specifying a command sequence to
.Ic bind-key ) .
+Note that all the commands, and the semicolons, must be separate words when
+running a tmux command sequence from a shell.
.Pp
-Examples include:
+Examples of tmux commands include:
.Bd -literal -offset indent
refresh-client -t/dev/ttyp2
@@ -360,6 +398,20 @@
new-window ; split-window -d
.Ed
+Or from
+.Xr sh 1 :
+.Pp
+.Bd -literal -offset indent
+$ tmux kill-window -t :1
+
+$ tmux new-window \\; split-window -d
+
+$ tmux new-session -d 'vi /etc/passwd' \\; split-window -d \\; attach
+.Ed
+.Pp
+See the
+.Sx EXAMPLES
+section for more.
.Sh CLIENTS AND SESSIONS
The following commands are available:
.Bl -tag -width Ds
@@ -424,18 +476,28 @@
.Op Fl n Ar window-name
.Op Fl s Ar session-name
.Op Fl t Ar target-session
-.Op Ar command
+.Op Ar shell-command
.Xc
.D1 (alias: Ic new )
Create a new session with name
.Ar session-name .
+.Ar window-name
+and
+.Ar shell-command
+are the name of and shell command to execute in the initial window.
+.Pp
The new session is attached to the current terminal unless
.Fl d
is given.
-.Ar window-name
-and
-.Ar command
-are the name of and command to execute in the initial window.
+The
+.Fl d
+option is required if
+.Ic new-session
+is being used in a command sequence, because all further commands
+are thrown out when attachment occurs.
+Use the
+.Ic attach
+command at the end of the sequence as necessary.
.Pp
If run from a terminal, any
.Xr termios 4
@@ -456,7 +518,7 @@
Giving
.Fl n
or
-.Ar command
+.Ar shell-command
are invalid if
.Fl t
is used.
@@ -824,6 +886,13 @@
.Ar src-window
to the specified
.Ar dst-window .
+Since tmux has no concept of windows belonging to a particular
+session, only links from sessions to windows, this means that both
+the "old" and "new" locations for the window work just the same as
+every other window, and everything done to the window from any link
+is reflected in every other link.
+This can be done across sessions, to create a window that can be interacted
+with from multiple sessions.
If
.Ar dst-window
is specified and no such window exists, the
@@ -861,7 +930,7 @@
.Op Fl dk
.Op Fl n Ar window-name
.Op Fl t Ar target-window
-.Op Ar command
+.Op Ar shell-command
.Xc
.D1 (alias: Ic neww )
Create a new window.
@@ -873,11 +942,11 @@
shown, unless the
.Fl k
flag is used, in which case it is destroyed.
-.Ar command
+.Ar shell-command
is the command to execute.
If
-.Ar command
-is not specified, the default command is used.
+.Ar shell-command
+is not specified, the value of the default-command option is used.
.Pp
The
.Ev TERM
@@ -905,7 +974,7 @@
.It Xo Ic pipe-pane
.Op Fl o
.Op Fl t Ar target-pane
-.Op Ar command
+.Op Ar shell-command
.Xc
.D1 (alias: Ic pipep )
Pipe any output sent by the program in
@@ -913,10 +982,10 @@
to a shell command.
A pane may only be piped to one command at a time, any existing pipe is
closed before
-.Ar command
+.Ar shell-command
is executed.
If no
-.Ar command
+.Ar shell-command
is given, the current pipe (if any) is closed.
.Pp
The
@@ -964,14 +1033,14 @@
.It Xo Ic respawn-window
.Op Fl k
.Op Fl t Ar target-window
-.Op Ar command
+.Op Ar shell-command
.Xc
.D1 (alias: Ic respawnw )
-Reactive a window in which the command has exited (see the
+Reactivate a window in which the command has exited (see the
.Ic remain-on-exit
window option).
If
-.Ar command
+.Ar shell-command
is not given, the command used when the window was created is executed.
The window must be already inactive, unless
.Fl k
@@ -1010,7 +1079,7 @@
.Ar size |
.Fl p Ar percentage Oc
.Op Fl t Ar target-pane
-.Op Ar command
+.Op Ar shell-command
.Xc
.D1 (alias: splitw )
Create a new pane by splitting
@@ -1351,10 +1420,10 @@
Set the number of buffers kept for each session; as new buffers are added to
the top of the stack, old ones are removed from the bottom if necessary to
maintain this maximum length.
-.It Ic default-command Ar command
+.It Ic default-command Ar shell-command
Set the command used for new windows (if not specified when the window is
created) to
-.Ar command ,
+.Ar shell-command ,
which may be any
.Xr sh 1
command.
@@ -1421,7 +1490,7 @@
.Ic lock-server
option is set.
The default is not to lock (set to 0).
-.It Ic lock-command Ar command
+.It Ic lock-command Ar shell-command
Command to run when locking each client.
The default is to run
.Xr lock 1
@@ -1572,7 +1641,7 @@
may contain any of the following special character sequences:
.Bl -column "Character pair" "Replaced with" -offset indent
.It Sy "Character pair" Ta Sy "Replaced with"
-.It Li "#(command)" Ta "First line of command's output"
+.It Li "#(shell-command)" Ta "First line of the command's output"
.It Li "#[attributes]" Ta "Colour or attribute change"
.It Li "#H" Ta "Hostname of local host"
.It Li "#F" Ta "Current window flag"
@@ -1584,8 +1653,8 @@
.It Li "##" Ta "A literal" Ql #
.El
.Pp
-The #(command) form executes
-.Ql command
+The #(shell-command) form executes
+.Ql shell-command
as a shell command and inserts the first line of its output.
Note that shell commands are only executed once at the interval specified by
the
@@ -2252,14 +2321,16 @@
Lock each client individually by running the command specified by the
.Ic lock-command
option.
-.It Ic run-shell Ar command
+.It Ic run-shell Ar shell-command
.D1 (alias: Ic run )
Execute
-.Ar command
+.Ar shell-command
in the background without creating a window.
-After the command finishes, any output to stdout is displayed in output mode.
+After the
+.Ar shell-command
+finishes, any output to stdout is displayed in output mode.
If
-.Ar command
+.Ar shell-command
doesn't return success, the exit status is also displayed.
.It Ic server-info
.D1 (alias: Ic info )
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users