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

Cannot send keycodes like <Space> or <Semicolon> #100

Open
Szymon-Wrzos opened this issue Jul 28, 2023 · 1 comment
Open

Cannot send keycodes like <Space> or <Semicolon> #100

Szymon-Wrzos opened this issue Jul 28, 2023 · 1 comment

Comments

@Szymon-Wrzos
Copy link

Szymon-Wrzos commented Jul 28, 2023

Using zsh, I'm trying to create mp_attach alias, that will launch zsh in proc and send provided command

Example of usage:
"mp_attach uvicorn main:app"
It need to be launched in zsh as I have set up automatic launching of venv

zsh -c doesn't do the trick

When it comes to space and semicolon, it throws an error: Error: Wrong key code: "Space" and Error: Wrong key code: "Semicolon" respectively

Usual < > and <:> causes similar error as well

Code:

function mp_attach() {
  command="$@"
  parts=(${(s[])command})
  mprocs --ctl "{c: add-proc, cmd: zsh" --server localhost:4050
  for char in $parts; do 
    echo $char
    if [[ $char == ' ' ]]; then
      mprocs --ctl "{c: send-key, key: <Space>}" --server localhost:4050
    elif [[ $char == ':' ]]; then 

      mprocs --ctl "{c: send-key, key: <Semicolon>}" --server localhost:4050
    else 
      mprocs --ctl "{c: send-key, key: <$char>}" --server localhost:4050
    fi
  done
  mprocs --ctl "{c: send-key, key: <Enter>}" --server localhost:4050

}

Result:
image

And in mprocs:
image

For 'add-proc' I launch zsh and the rest of commands are ignored

@pvolok
Copy link
Owner

pvolok commented Jul 30, 2023

Thank you for a very detailed explanation. Unfortunately, currently it's impossible to send these keys. I just added most basic keys and never describes the rest of the keys.

I will add more keys in the next version, or feel free to send a PR.

@Szymon-Wrzos Szymon-Wrzos changed the title Cannot send keycodes like <Space> or <Semicolor> Cannot send keycodes like <Space> or <Semicolon> Oct 2, 2023
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