On Wed, Jan 20, 2010 at 03:06:45PM -0800, Robin Lee Powell wrote:
> On Wed, Jan 20, 2010 at 11:39:40PM +0100, Michel Le Cocq wrote:
> > With my old screen I had an alias : smail wich launch screen with
> > a special .screenrc like this :
> > 
> > screen -t boiteA mutt -F $HOME/.mutt/config/.muttrc_A
> > screen -t boiteB mutt -F $HOME/.mutt/config/.muttrc_B
> > screen -t BoiteC mutt -F $HOME/.mutt/config/.muttrc_C
> > screen -t sync offlineimap
> > 
> > How can I did this with tmux ?
> > 
> > I tried something like this but it's not good :
> > tmux new-session 'emacs -nw' new-session 'man man'
> 
> That certainly isn't what you want, because you want those things in
> multiple windows in the same session.  Try this:
> 
> tmux new-session -d 'man man' \; new-window 'emacs -nw' \; attach
> 
> Giant aside, leading to some extremely minor feature requests:
> 
> There is, in general, a bit of a quoting problem with the [command]
> argument to tmux commands, and a definitional issue about what they
> can take (can they take shell commands? all of them? how does it
> tell?)
> 
> It looks like new-session and new-window, at least, can take shell
> commands there, and a ; at the front lets them know it's *not* a

No, I think you misunderstand.

tmux new-session -d 'man man' \; new-window 'emacs -nw' \; attach
     ^^^^^^^^^^^^^^^^^^^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^    ^^^^^^
           command 1                  command 2             cmd 3

These are each /separate/ commands, not arguments to new-session.

So, this command line is the equivalent of:

tmux new-session -d 'man man'
tmux new-window 'emacs -nw'
tmux attach

tmux separates its commands with ;s because that is the standard command
separator. If you use it from the shell, you have to escape those ;s because
otherwise the shell will interpret them. There is nothing funny about this,
find has the same thing because it uses ; as a terminator.

If you use the same command sequence from the tmux command prompt you don't
need to escape the ;s because the shell is not involved.

You do still need to quote the shell commands, because the new-session and
new-window commands require those to be one argument (as does every other tmux
command which accepts shell commands).

> shell command (which is odd, since that's a shell metacharacter),
> and you can't quote the whole thing on the command line because it
> relies on shell word breaking, but you *must* quote the shell
> commands if they're more than one word.

tmux can of course parse commands fully itself, it does it for the config file
and command prompt, but getting the shell not to do it for us means everyone
has to quote their entire set of commands - this would break everyone's
scripts, as well as being counterintuitive for general use (tmux new -d vs tmux
'new -d'). It isn't feasible, even if it would be neater in cases which
currently require escaping.

You have a point about overloading of "command" in the man page, Perhaps we
should always say "shell-command" or "shell command" and reserve "command" for
"tmux commands", although the former is the majority. Diffs are welcome.
 
> A bit confusing.
> 
> Seems to me like there should be exactly one tmux command, call it
> "run-shell", that takes a shell command, and if you want to run a
> shell command you have to use that.

Anywhere that accepts a shell command it doesn't make any sense to accept a
tmux command so I think this would just be redundant syntax.

Someone suggested allowing -- for shell commands, there may be some mileage in
that but it would have to be backwards compatible (ie if there is a -- in the
place the command string should be, merge the rest of argv together into a
string, else treat it as one command).

> Have the documentation specify
> that on the command line, the shell command must all be one
> shell-word.  Or just specify that it has to always be quoted, which
> seems easier.

Well, in most cases we say '[command]' rather than '[command] [arguments]'
which implies it is one argument, although it could be clearer. The tmux man
page isn't the place to talk about shell quoting, we define what tmux accepts,
the shell man page defines how to quote it (remember shells can have different
quoting rules).

> It would also be nice if the word breakup happened afterwards, but I
> can understand wanting the simplicity of relying on the shell for
> that, from a coding perspective.
> 
> -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/
> 
> ------------------------------------------------------------------------------
> 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

------------------------------------------------------------------------------
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

Reply via email to