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

How to run a second command when the first command fails? e.g., tmux attach || tmux #5740

Open
jcjolley opened this issue Jun 8, 2022 · 5 comments
Labels
enhancement New feature or request Stale used for marking issues and prs as stale

Comments

@jcjolley
Copy link

jcjolley commented Jun 8, 2022

In other shells, I would run tmux attach || tmux to resume a tmux session if one exists, or create one if it doesn't.

I crawled the docs and couldn't find an equivalent to this.
I read #740 and #1352, but neither of them addressed the OR case.

@fdncred
Copy link
Collaborator

fdncred commented Jun 8, 2022

you are correct. i don't believe we support it yet, but we want to.

@onthebridgetonowhere onthebridgetonowhere added the enhancement New feature or request label Jun 8, 2022
@DominicDams
Copy link

I think a work around is using an if and complete
i.e.

if ((tmux attach | complete | get exit_code) == 1) {
    tmux
}

But I agree this functionality would be nice

@dheater
Copy link

dheater commented Aug 21, 2022

I started work on this so I'll go ahead and post a draft MR #6374

I've only got some initial parsing done. I've not figured out how to break the commands into conditionally executed blocks.

@fdncred
Copy link
Collaborator

fdncred commented Aug 21, 2022

Semi colon works now like command;command2

@dheater
Copy link

dheater commented Aug 21, 2022

Semi colon works now like command;command2

Yes, but that doesn't provide shortcut semantics so there is not a convenient way to do something like if file exists foo && ./foo.

@github-actions github-actions bot added the Stale used for marking issues and prs as stale label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale used for marking issues and prs as stale
Projects
None yet
Development

No branches or pull requests

5 participants