OS: macOS Catalina 10.15 (19A602)
app: espanso 0.5.3
I can use passive mode with the given :greet example in the documentation, but the :rev example results in an empty string.
1) Does somebody else experience this problem (on mac os)? I have disabled all other tools that use my keyboard.
- trigger: ":rev"
replace: ""
passive_only: true
vars:
- name: output
type: shell
params:
cmd: "echo $0 | rev"
trim: true
And if I forget to finish the string with a slash (e.g. :rev/arg1 instead of :rev/arg1/ ) it deletes the copied string and results in a v and sometimes it pastes everything that was in my clipboard and sometimes it just pastes the given argument like this: /arg1.
2) Shouldn't it ignore the string and just leave it as it is? I just discovered this tool, but I assume that you cut the string, process it in your backend and paste the result back?
Hey @oceanByte,
OS: macOS Catalina 10.15 (19A602)
app: espanso 0.5.3I can use passive mode with the given
:greetexample in the documentation, but the:revexample results in an empty string.
- Does somebody else experience this problem (on mac os)? I have disabled all other tools that use my keyboard.
- trigger: ":rev" replace: "" passive_only: true vars: - name: output type: shell params: cmd: "echo $0 | rev" trim: true
That's pretty strange indeed, could you please post the output of espanso log here?
And if I forget to finish the string with a slash (e.g.
:rev/arg1instead of:rev/arg1/) it deletes the copied string and results in a v and sometimes it pastes everything that was in my clipboard and sometimes it just pastes the given argument like this:/arg1.
- Shouldn't it ignore the string and just leave it as it is?
I'll make a few tests with the example you proposed and get back to you once I know something :)
I just discovered this tool, but I assume that you cut the string, process it in your backend and paste the result back?
That's right.
Please bare in mind that, as of now, passive mode is still experimental, so expect some rough edges around it :) That said, let me know if you experience other errors, as good feedback is the best way to improve espanso.
Thanks for your help :)
Thanks for the quick reply @federico-terzi Lovely tool!
Please bare in mind that, as of now, _passive mode_ is still experimental, so expect some rough edges around it :) That said, let me know if you experience other errors, as good feedback is the best way to improve espanso.
Everything seems to work so far, it's just the bash shell integration with passive mode that causes these problems (and I haven't tested other scripts with passive mode yet).
I am not sure if the espanso log is too helpful but here it is:
20:02:24 [ INFO] espanso version 0.5.3
20:02:24 [ INFO] using config path: /Users/username/Library/Preferences/espanso
20:02:24 [ INFO] using package path: /Users/username/Library/Application Support/espanso/packages
20:02:24 [ INFO] starting daemon...
20:02:24 [ INFO] Status icon already initialized, skipping.
20:02:24 [ INFO] Initializing EspansoNotifyHelper in /Users/username/Library/Application Support/espanso
20:02:24 [ INFO] EspansoNotifyHelper already initialized, skipping.
20:02:24 [ INFO] Binded to IPC unix socket: /Users/username/Library/Application Support/espanso/espanso.sock
20:02:24 [ INFO] espanso is running!
20:02:29 [ INFO] Passive mode activated
@oceanByte Indeed, you log looks perfect! :)
I have a doubt, does running echo hello | rev on a macOS terminal produce the expected result? because now that I think about it, I only tested that particular passive command on Linux and not on macOS.
Cheers :)
I have a doubt, does running
echo hello | revon a macOS terminal produce the expected result? because now that I think about it, I only tested that particular passive command on Linux and not on macOS.
Valid question since sometimes macOS uses custom implementations (e.g. sed on macOS does not behave like GNU sed). echo hello | rev works as expected though.
I have the same problem with other bash/shell commands and espanso's passive mode. It also fails for other scripts (tested with node/python): It always results in an empty string. I haven't used any arguments this time and tried to print _hello world_.
Maybe it's just a custom setting on my system after all. I will setup a new system and report if this also happens on a freshly installed system.
Hey @oceanByte,
Sorry for the late reply. That is interesting indeed and most likely a bug! I'll take a look at it in the next few days so that, Hopefully, we can get this sorted out before the next release.
Cheers :)
Maybe it's just a custom setting on my system after all. I will setup a new system and report if this also happens on a freshly installed system.
I just tested the passive mode on a freshly installed MacOS Catalina (10.15.4 (19E266)) and the error still happens. Test cases (input => output):
Test 1: :rev/arg1 => /arg1
Result: Espanso pastes first argument with a slash
Test 2: :rev/arg1/ => :rev/arg1/
Result: Espanso cuts the string and pastes the exact same string back
Test 3: :rev/arg1/arg2 => arg2
Result: argN behaves the same. Espanso always pastes the very last argument without the slash
Test 4: :rev/arg1/arg2/ => :rev/arg1/arg2/
Result: Same as _Test 2_
Let me know if I can offer additional help to improve Espanso.
Hey @oceanByte,
I finally sorted it out! (honestly I find it pretty hilarious, and I'm sorry I've noticed only now).
Due to the way Jekyll (the templating engine I'm using for the documentation) works, the example in the docs got stripped out of the most important thing, the variable output!
You see, in the example you posted:
- trigger: ":rev"
replace: ""
passive_only: true
vars:
- name: output
type: shell
params:
cmd: "echo $0 | rev"
trim: true
The output variable is not rendered anywhere! What you should do instead, is adding its output in the "replace" string:
- trigger: ":rev"
replace: "{{output}}"
passive_only: true
vars:
- name: output
type: shell
params:
cmd: "echo $0 | rev"
trim: true
I'm really sorry I've only noticed it now, I'll update the docs as soon as I can!
Test 1: :rev/arg1 => /arg1
Result: Espanso pastes first argument with a slash
This is expected, as the passive mode makes use of a regex (passive_match_regex) that expects a slash after the arguments, so omitting the last slash causes espanso to ignore the argument altogether and render only the first part of the match :rev (which indeed outputs the empty string, as it doesn't have any output).
That said, you could modify that regex in the config so that instead of considering a slash, it also considers space characters \s.
Thank you very much for you help :)
Most helpful comment
Hey @oceanByte,
I finally sorted it out! (honestly I find it pretty hilarious, and I'm sorry I've noticed only now).
Due to the way Jekyll (the templating engine I'm using for the documentation) works, the example in the docs got stripped out of the most important thing, the variable output!
You see, in the example you posted:
The output variable is not rendered anywhere! What you should do instead, is adding its output in the "replace" string:
I'm really sorry I've only noticed it now, I'll update the docs as soon as I can!
This is expected, as the passive mode makes use of a regex (
passive_match_regex) that expects a slash after the arguments, so omitting the last slash causes espanso to ignore the argument altogether and render only the first part of the match:rev(which indeed outputs the empty string, as it doesn't have any output).That said, you could modify that regex in the config so that instead of considering a slash, it also considers space characters
\s.Thank you very much for you help :)