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

tmuxp pass args to tmux #171

Open
JBKahn opened this issue Jun 24, 2016 · 27 comments
Open

tmuxp pass args to tmux #171

JBKahn opened this issue Jun 24, 2016 · 27 comments
Labels

Comments

@JBKahn
Copy link

JBKahn commented Jun 24, 2016

Is there a way (can't find any) to pass an arbitrary arg to tmux? I want to pass -CC but I don't see an easy way to do that and I'm not familiar with the packages you're using so I'm not sure where in the code this would have to be.

@tony
Copy link
Member

tony commented Jun 24, 2016

I need to know what behavior you're looking to get to be sure.

I believe load_workspace and command_load

I can add a -C and -CC option to pass those arguments after the building is complete and you attach the session. Is that what you're looking for?

@JBKahn
Copy link
Author

JBKahn commented Jun 24, 2016

This is the integration I'd like to make use of, but it seems somewhat complicated. I don't know if it matters that it launches a new terminal to do this:
https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration

@JBKahn
Copy link
Author

JBKahn commented Jul 7, 2016

not necessary, I can just create it with -d then attach and all works.

@JBKahn JBKahn closed this as completed Jul 7, 2016
@maxekman
Copy link

It would be nice to be able to pass flags to tmux on startup. I would like to use it for iTerm integration like @JBKahn. I think it is reasonable for tmuxp to allow it as one of its purposes is to make it easy to start and use sessions. tmuxp load -d file.yaml && tmux attatch -t session is a bit too long when it could be done like tmuxp -CC load file.yaml for example.

@nomasprime
Copy link

nomasprime commented Feb 2, 2021

Has anyone got this working?

tmuxp load -d … outputs tmux: unknown option -- d

@tony tony pinned this issue Feb 2, 2021
@tony tony reopened this Feb 2, 2021
@tony
Copy link
Member

tony commented Feb 2, 2021

The commands aren't pass-thru at of now, but I think it makes sense for us to use tmux(1)'s args wherever possible

We recently introduced window appending, which overlaps with tmux's -a. I assume since attach is default we're in the clear in that regard

@tony tony unpinned this issue Feb 2, 2021
@tony tony added the pinned label Feb 2, 2021
@tony
Copy link
Member

tony commented Feb 2, 2021

I added a pinned label so the cleanup bot won't close this

@nomasprime
Copy link

Thanks @tony.

I'm fairly new to tmux so still stumbling around in the dark quite a lot.

Thought iTermocil might be better for iTerm but ironically it blows up when using its tmux integration.

Found a comment proposing tmuxinator and a sample config. Can tmuxp be configured similarly, my impression is pass-thru commands would be required or did I misunderstand?

@tony
Copy link
Member

tony commented Feb 3, 2021

I never heard of itermocil - and it's cool you bring it up

I'd need to take a peek at it, but unfortunately I don't have a mac to try it with

And... they use python, kind of interesting why they don't use tmuxp / libtmux.

So if we have a mac user that can test, maybe it'd be possible for an integration to happen

I think in the mean time if you want to use iTerm, you mean want to use teamocil / tmuxinator / etc in the meantime, unless someone else with macOS can step into help us (Any takers?)

@leeand00
Copy link

leeand00 commented Sep 5, 2022

I found this thread trying to look for how to launch tmuxp passing argument to it; the way that you could in tmuxinator. But it seems like that is rather ruby-specific.

In the mean time I guess I can just use environment variables.

@tony
Copy link
Member

tony commented Sep 5, 2022

@leeand00 Do either of these help?

https://tmuxp.git-pull.com/configuration/examples.html#environment-variable-replacing, https://tmuxp.git-pull.com/configuration/examples.html#environment-variables

Assume test_env_vars.yaml:

session_name: ${SESSION_NAME}
windows:
- window_name: ${WINDOW_NAME}
  panes:
  -
$ env SESSION_NAME='my session' WINDOW_NAME='a window' tmuxp load ./test_env_vars.yaml

@leeand00
Copy link

leeand00 commented Sep 5, 2022

That works great except I can't pass any of the env cars to my shell cmds.

@tony
Copy link
Member

tony commented Sep 6, 2022

@leeand00 That may be the case - not sure. It could be something we could add

Can you give an example config file so I can try?

@leeand00
Copy link

leeand00 commented Sep 6, 2022

session_name: ${SESS_TITLE}
windows:
- window_name: ${BOX}
  panes:
    - shell_command:
      - echo ${BOX}

echos ${BOX} as opposed to what I passed into it.

Also it's not an available environment variable either within the shell that opens.

@tony
Copy link
Member

tony commented Sep 6, 2022

I was able to do it here, slightly different syntax:

session_name: ${SESSION_NAME}
windows:
- window_name: ${WINDOW_NAME}
  panes:
  - echo ${WINDOW_NAME}
env SESSION_NAME='my session' WINDOW_NAME='a window' tmuxp load ./test_env_vars.yaml

That work?

@tony
Copy link
Member

tony commented Sep 6, 2022

Also I was able to do it with this too:

session_name: ${SESSION_NAME}
windows:
- window_name: ${WINDOW_NAME}
  panes:
  - shell_command:
    - echo ${WINDOW_NAME}

echos ${BOX} as opposed to what I passed into it.

What command are you running?

@tony
Copy link
Member

tony commented Sep 6, 2022

@leeand00 Forgot to tag you ^

@leeand00
Copy link

leeand00 commented Sep 6, 2022

@tony

Also I was able to do it with this too:

session_name: ${SESSION_NAME}
windows:
- window_name: ${WINDOW_NAME}
  panes:
  - shell_command:
    - echo ${WINDOW_NAME}

echos ${BOX} as opposed to what I passed into it.

What command are you running?

env SESSION_NAME='my session' BOX='CMPNAMEPOS1' tmuxp load ./me-yml-file.yml -d

@tony
Copy link
Member

tony commented Sep 6, 2022

@leeand00 This works for me. I think you can do it.

Maybe there's a typo somewhere? Try on a new shell / terminal without other stuff running? (e.g. kill tmux and have a new terminal window)

tmuxp -V, tmux -V, python -V? What shell are you using? tmuxp debug-info?

@leeand00
Copy link

leeand00 commented Sep 6, 2022

@tony

tmuxp 1.5.4
tmux 3.0a
Python 3.8.2 (had to run python3, not python)

tmuxp debug-info
Usage: tmuxp [OPTIONS] COMMAND [ARGS]...
Try "tmuxp --help" for help.

Error: No such command "debug-info".

@tony
Copy link
Member

tony commented Sep 6, 2022

@leeand00 Where did you install tmuxp from?

Current version is 1.13.1, here's the changelog since 1.5.4: https://github.com/tmux-python/tmuxp/blob/v1.13.1/CHANGES

Any chance you can update?

@leeand00
Copy link

leeand00 commented Sep 7, 2022

@tony from apt-get WSL2, Ubuntu 20.04 LTS

Is there a dpkg? Or pip?

@tony
Copy link
Member

tony commented Sep 7, 2022

@tony from apt-get WSL2, Ubuntu 20.04 LTS

Is there a dpkg? Or pip?

Think you could try to use pipx to get a more recent tmuxp version?

What shell are you using? Bash? zsh? fish? dash? echo $SHELL may tell.

@leeand00
Copy link

leeand00 commented Sep 8, 2022

@tony I'm using bash. I never heard of pipx.

Why would I have to use it to install the latest version?

@leeand00
Copy link

leeand00 commented Sep 21, 2022

@tony Okay I installed pipx 0.12.3.1.

The command for installation I found on the main page doesn't appear to work (for me at least)

# pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
usage: pipx [-h] [--version] {install,inject,upgrade,upgrade-all,uninstall,uninstall-all,reinstall-all,list,run,ensurepath} ...
pipx: error: unrecognized arguments: --suffix=@next

@tony
Copy link
Member

tony commented Sep 22, 2022

@leeand00 Hmm.

It seems pipx's argument signature may change

pip install --user -U tmuxp
~/.local/bin/tmuxp

Does that work?

You may need to add ~/.local/bin to PATH:

if [ -d "$HOME/.local/bin" ]
then
    export PATH=$PATH:$HOME/.local/bin
fi

In lieu of all the above: I think it depends what fits your style. I would encourage searching online for whichever angle you would like to get caught up with pip install --user and pipx.

My only hesitation is, if I sent more commands on their own, I'm afraid it could bork your python installation.

It may be a prerequisite to familiarize pip and pipx and shell configuration (e.g. ~/.bashrc, ~/.zshrc, depending on your shell) - since those are needed in order to reason about the above.

@m-faith
Copy link

m-faith commented Feb 12, 2023

Tmuxinator can pass args to tmux like so...

tmux_options: -f ~/.tmux.mac.conf.

I thought Tmuxp could do this just as well as Tmuxinator. Am I mistaken about the method for this?

Related: #867

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

No branches or pull requests

6 participants