Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quoted commands fail #7

Closed
brandondrew opened this issue Sep 29, 2016 · 2 comments
Closed

Quoted commands fail #7

brandondrew opened this issue Sep 29, 2016 · 2 comments

Comments

@brandondrew
Copy link

Certain commands are not (AFAIK) possible with ttab, because of precedence rules.

ttab -t 'code & git' (git branch; git status)
ttab -t 'code & git' (git branch && git status)

It might seem that putting quotes around the command would fix this, passing it all to ttab as a single argument that could be unpacked before being issued to the shell, but it does not work.

Allowing the command and its arguments to be either single or double quoted (but not requiring it!) would be very helpful, as it would allow commands like those given above to succeed.

@mklement0
Copy link
Owner

mklement0 commented Sep 30, 2016

The man page states (emphasis added):

To specify multiple commands, use eval followed by a single, quoted
string
containing the entire shell command line to execute; in the simplest
case, enclose the string in single-quotes and use ; to separate com-
mands.

Thus, you'd have to specify

 ttab -t 'code & git' eval 'git branch && git status'

mklement0 added a commit that referenced this issue Oct 1, 2016
  * [new feature] `-q` now allows clearing the "screen" of the new tab after
     opening using `clear`, assuming any command (list) passed succeeded.
  * [enhancement] A quoted multi-command shell command string can now be
    specified as a single - and only - operand, without having to precede with
    an explicit `eval` command.
  * [behavior change] If no custom title is specified with `-t <title>`, no
    attempt is made anymore to auto-derive a meaningful tab title from the
    shell command specified, as there is no heuristic that works well in all
    cases.
  * [fix] [Issue #7](#7): iTerm2
    now also preserves the current working dir. when opening a new tab in the
    current window.
@mklement0
Copy link
Owner

I realized that I could make the eval implicit, so if you install the just-released v0.5.0), you can omit it:

 ttab -t 'code & git' 'git branch && git status'

In other words: you can now pass any shell command line as a single, quoted string as the one and only operand (non-option) to ttab to have it executed in the new tab.

Note that quoting the command line is invariably a requirement, as the current shell would otherwise interpret metacharacters such as ;, (, ) and &, before ttab ever gets to see the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants