Making ZSH work nicely with [
and [[
#18
Replies: 4 comments 3 replies
-
Awesome! I think there is a slightly more concise way to implement import pkg_resources
for ep in pkg_resources.iter_entry_points('console_scripts'):
if ep.module_name.startswith('refinery'):
print(ep.name) Could you check if this works well for you? I am contemplating how to best add this to the documentation. Options I see:
I am currently gravitating towards the second option. What do you think? |
Beta Was this translation helpful? Give feedback.
-
Nice, your code is indeed much nicer. 😊 (I'm not that deep into python packaging magic). I went on to glue this into a single shell script. I think that would make it easier to copy-paste just a single script, rather than two files. #!/usr/bin/zsh
function alias-noglob {
while read -r entrypoint; do
alias $entrypoint="noglob $entrypoint"
done
}
python <<EOF | alias-noglob
import pkg_resources
for ep in pkg_resources.iter_entry_points('console_scripts'):
if ep.module_name.startswith('refinery'):
print(ep.name)
EOF About where to put it: I also think the second option is best. That would even allow you to put the shell script itself into that subdirectory, allowing folks to grab it via raw.github.com. Adding yet another alternative to copy-pasting. |
Beta Was this translation helpful? Give feedback.
-
Sorry for the delay! If you want at least some of your duly deserved credit, you could open a PR that adds the file to a new root directory called "zsh". I'll add some README text around it after. If you prefer that I add it myself, just let me know. |
Beta Was this translation helpful? Give feedback.
-
Awesome! Although I'll warn you that I will probably not accept anything as a unit that does network callouts, but feel free to try and change my mind ;-). |
Beta Was this translation helpful? Give feedback.
-
Frames don't work well with zsh out-of-the-box, since zsh interprets the double square brackets
[[
. It errors withzsh: bad pattern: [[
.One could just escape the brackets, but I found a workaround for this. My workaround consists of a little python script, with code I stole from your setup.py and a small shell script for zsh.
list-entrypoints.py
init.sh
Usage
When I want to use binary-refinery, I now just do
source init.sh
and the noglob-alias handles this issue.Feel free to use these snippets. If you want, you can also include these scripts in the repo and/or docs. 😊
Beta Was this translation helpful? Give feedback.
All reactions