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 escape the dollar sign? #945

Open
yuis-ice opened this issue Sep 8, 2024 · 1 comment
Open

How to escape the dollar sign? #945

yuis-ice opened this issue Sep 8, 2024 · 1 comment

Comments

@yuis-ice
Copy link

yuis-ice commented Sep 8, 2024

Here's an example tmuxp yaml config part:

    panes:
      - shell_command:
        - autossh -t -p 30360 tmp@localhost 'PATH=~/.nvm/versions/node/v20.16.0/bin:$PATH && cd pg && npx local-web-server -p 30361'

The problem is simply, the $PATH part expands on the tmux session (what I do not desire and expect) which breaks the command, so I need to disable the feature (?) or safely escape such character(s).

@joseph-flinn
Copy link
Contributor

It seems like the expansion of all environment variables comes from this line:

return os.path.expandvars(os.path.expanduser(value)) # NOQA: PTH111

It doesn't look like there is currently a way to escape the dollar sign. I'll have to look further into the different cases where environment variables should and should not be expanded before proposing a solution.

Debugging notes to future self
  • Manually running :send-keys "echo '$PATH'" Enter in tmux expands $PATH
  • Manually running :send-keys 'echo "$PATH"' Enter in tmux does not expand $PATH
  • pane.send_keys("PATH=$PATH") works as expected (does not expand in pane)
    • Can quickly be tested tmuxp shell
    • Implies that libtmux.pane.cmd() works as expected
    • Implies that libtmux.server.cmd() works as expected
  • The issue has to be with how the command is loaded from the config
  • Found it: tmuxp.workspace.loader.expandshell() defaults to expanding all $ and ${} with the user's local environment

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