jj
jj copied to clipboard
document how to use powershell and elvish completions
i added support for these in #2945 but wasn't able to figure out how to actually use them in the respective shells. it would be nice to document how to do that; i don't use these shells so i don't know.
Invoke-Expression
looks like the right thing for powershell, but when i try Invoke-Expression [String]$(cargo r -- util completion powershell)
it complains that it doesn't like the using
token. i'm not sure if that's specific to powershell on windows or something like that?
elvish i couldn't get working at all, it complained about invalid syntax. i think ubuntu might package an ancient version or something like that.
Originally posted by @jyn514 in https://github.com/martinvonz/jj/pull/2945#discussion_r1477437430
For elvish, maybe you ran into https://github.com/clap-rs/clap/issues/4265? (Oh, look, I filed that issue. I have no memory of that.)
Current Version
- jj 0.14.0-8e4d1af98eccf1ed8a79a7ddf9500467aa7684f5
- PowerShell 7.4.1
On powershell, only the .
operator can be used (instead of Invoke-Expression
), but I believe there are some encoding issue with the current implementation, here is my current profile file:
# jj completion
$jjc = [ScriptBlock]::Create([system.String]::Join("`n",$(jj util completion powershell).split("`n")))
# can't do this
# $jjc = [ScriptBlock]::Create($(jj util completion powershell))
. $jjc
I can't create a ScriptBlock
just from $(jj util completion powershell)
.
But writing the script to a file and then using the .
operator is fine:
jj util completion powershell > jjc.ps1
. .\jjc.ps1
This could be a clap issue as well?
Update
Aha! That problem has been solved by clap. (found by jj user actually)