zpyi
zpyi copied to clipboard
division
I love this. Thanks!
I'm wondering if I am doing something wrong or if it isn't supported, but I can't seem to do division.
$ '120/60
Gives zsh: no such file or directory: 120/60
Seems weird. So you also need to close the opened single quote. But in this special case, you can actually skip the quotes too. Simply:
120/6
seems to work. The logic is: If ZSH sees a command which it cannot interpret (maybe like sadsdasda, or maybe '2**120', note the single quotes around the expression, to ensure zsh does not think of it as a wildcard globbing pattern), it will pass it on to zpyi.
So 120/6 simply works, since zsh does not see it as anything valid. For more complicated expressions, you need " or ' around the expression to let zsh know it is a whole single expression.
@chadgh Is this issue resolved? P.S. I've updated the README with a comprehensive description of all the features with examples.
Sorry, the example I put up didn't have the closing quote, but when I am doing this on the command line it does have the closing quote and does not work as advertised.
I've tried with ', ", and no quotes and it always gives me the same result:
zsh: no such file or directory: 120/60
I thought it might have something to do with the zsh plugins/options I have turned on, but so far shutting them off hasn't made it work.
@chadgh That issue hints at a wrong installation. Are you sure you have sourced the zpyi.zsh file? Because if that had been done, it should not have printed that error. That is the most probable solution, refer to the installation section and see if the file has been sourced in your .zshrc file. Let me know if it solves the problem.
Also, try '2+3' as well, although if the above file has not been sourced, it wouldn't work either.
'2+3' works perfectly. I've tried math operations for +, -, , *, %. Those all work great. Even other python code works.
There must be something strange with either my setup or the way it is working because it doesn't seem to like the / character.
As another example, I'm assuming this should work:
'print("http://google.com")'
but it fails with:
zsh: no such file or directory: print("http://google.com")
This is bewildering! If it is showing the error zsh: no such file or directory, that usually means the command_not_found handler wasn't registered. But if you say other python code works but the above 2 lines with / don't... it beats me! All that seems to work fine on my setup, and apparently for the other people who're did PRs/issues etc.
Can you:
mv .zshrc .zshrc.old
echo "source ~/.zpyi/zpyi.zsh" > .zshrc
exit
# open a new shell
'120/6'
# see if it works
mv .zshrc.old .zshrc
Sorry for the code, its much easier to describe the intention unambiguously with code :smile:
No problem. I totally get that.
So I did that and unfortunately it still didn't work. I can tell it took effect because I have a different prompt now and the other python code examples work, but the / stuff still doesn't work.
Just in case it might help, I'm running zsh 5.2. I'm not sure if that makes a difference or not.
The only thing I can think of is, maybe your terminal emulator is playing tricks. Which terminal do you use? (Gnome terminal, urxvt, st, xterm). I use urxvt. Do you use tmux or screen? Such things.
I also use zsh 5.2.
A better way to debug this would be either one of:
- Use IRC to talk (I'm always online as
acehack, orsaksham). You can ping me there if you want. - There's something called
tmatewhich lets you provide a shared shell (where you can see what the other person is doing). Not sure how that'd work, but a friend of mine suggested this solution.
I'm really curious about this issue :confused: If only I could reproduce this. Let me know the terminal atleast.
I'm using terminator and do work in tmux.
That, however, doesn't seem to be the problem either. I tried in both xterm and urxvt with no tmux and am getting the same result (most things working, / stuff not).
I also tried just the simplified .zshrc file, but it still didn't work.
I tried sending a message on IRC, but I'm not too familiar with it and am not sure I sent a message correctly. :frowning:
Don't worry too much about it. It it is really just my setup then I'll eventually figure out a way to get it to work and will update this issue.
You did send the messages correctly. Just that I was asleep at that time :smile: (My client keeps me online all the time). In any case, let me know if you figure this out sometime! Meanwhile, you could use the sys.argv array to pass strings with slashes (for that http://google.com thing).
Probably because of the slash, ZSH treats it as a directory. Maybe there is a similar handler, for no file or directory (file_directory_not_found, maybe)?
I see what you mean. But the program is in a single quoted environment, nothing should take effect inside that AFAIK. Are you experiencing the same issue?
No, works for me (zsh 5.2, prezto, Arch Linux, default python is python 3, terminal emulators: tilda and konsole):
$ 25/5
5.0
Pretty sure it's either a problem with @chadgh's zsh version or terminal emulator.
@chadgh Can you test with another emulator?
Still doesn't work for me (zsh 5.2, Arch Linux, default python is python 3 (3.5.1), terminal emulators: terminator and xterm)
Works on xterm...
Maybe the zpyi version is old? There have been a few commits since the report date.
Just updated. No luck :(
Try running zsh in 'safe mode':
$ zsh -f
hostname% source ~/.zpyi/zpyi.zsh
hostname% 25/5
5.0 # Hopefully...
:( I'm really at a lose here. I did that exactly and got the same thing
zsh: no such file or directory: 25/5
What about Python's floor division operator: 25//5?
Nope, same thing.
@chadgh Am I correct in assuming '25 / 5' works, but '25/5' doesn't?