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

division #4

Open
chadgh opened this issue Sep 16, 2016 · 23 comments
Open

division #4

chadgh opened this issue Sep 16, 2016 · 23 comments

Comments

@chadgh
Copy link

chadgh commented Sep 16, 2016

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

@sakshamsharma
Copy link
Owner

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.

@sakshamsharma
Copy link
Owner

@chadgh Is this issue resolved? P.S. I've updated the README with a comprehensive description of all the features with examples.

@chadgh
Copy link
Author

chadgh commented Sep 19, 2016

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.

@sakshamsharma
Copy link
Owner

@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.

@chadgh
Copy link
Author

chadgh commented Sep 20, 2016

'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")

@sakshamsharma
Copy link
Owner

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 😄

@chadgh
Copy link
Author

chadgh commented Sep 20, 2016

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.

@sakshamsharma
Copy link
Owner

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, or saksham). You can ping me there if you want.
  • There's something called tmate which 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 😕 If only I could reproduce this. Let me know the terminal atleast.

@chadgh
Copy link
Author

chadgh commented Sep 20, 2016

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. 😦

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.

@sakshamsharma
Copy link
Owner

You did send the messages correctly. Just that I was asleep at that time 😄 (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).

@bharadwaj-raju
Copy link

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)?

@sakshamsharma
Copy link
Owner

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?

@bharadwaj-raju
Copy link

No, works for me (zsh 5.2, prezto, Arch Linux, default python is python 3, terminal emulators: tilda and konsole):

$ 25/5
5.0

@bharadwaj-raju
Copy link

bharadwaj-raju commented Nov 8, 2016

Pretty sure it's either a problem with @chadgh's zsh version or terminal emulator.

@chadgh Can you test with another emulator?

@chadgh
Copy link
Author

chadgh commented Nov 8, 2016

Still doesn't work for me (zsh 5.2, Arch Linux, default python is python 3 (3.5.1), terminal emulators: terminator and xterm)

@bharadwaj-raju
Copy link

Works on xterm...

@bharadwaj-raju
Copy link

Maybe the zpyi version is old? There have been a few commits since the report date.

@chadgh
Copy link
Author

chadgh commented Nov 8, 2016

Just updated. No luck :(

@bharadwaj-raju
Copy link

bharadwaj-raju commented Nov 8, 2016

Try running zsh in 'safe mode':

$ zsh -f
hostname% source ~/.zpyi/zpyi.zsh
hostname% 25/5
5.0  # Hopefully...

@chadgh
Copy link
Author

chadgh commented Nov 8, 2016

:( I'm really at a lose here. I did that exactly and got the same thing

zsh: no such file or directory: 25/5

@bharadwaj-raju
Copy link

What about Python's floor division operator: 25//5?

@chadgh
Copy link
Author

chadgh commented Nov 8, 2016

Nope, same thing.

@pallavagarwal07
Copy link

pallavagarwal07 commented Feb 25, 2017

@chadgh Am I correct in assuming '25 / 5' works, but '25/5' doesn't?

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

4 participants