-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Not working on zsh? #4
Comments
I just had to fight a bit on that. There are several issues with zsh, which I manually solved, might propose a better solution if I don't forget. Anyway the changes I made : ConditionsConditions must use the
read function
pick_word() {
raw=$1
words=(${(@s:/:)raw})
index=$(($RD_NUMBER % ${#words[@]}))
echo "${words[$index + 1]}"
} Array indexNote that in bash, arrays start at 0, but they start at 1 in zsh, meaning that you would need an offset. Random generatorThe random generator is not reseeded inside a subshell, meaning that you would always have the same result each time. To solve this I added this line to the beginning of the RD_NUMBER=$RANDOM If you want, I can provide my edited file, but I'm pretty sure it only works with zsh, wich makes it more of a quick and dirty hack than an actual solution. |
The |
I'll try to make a PR on the weekend or next week, depending on my schedule, I should be able to make it work with both zsh and bash |
This commit introduces several fixes to make sure the program works in bash and zsh - conditions use the correct [[]] syntax - the random generator has been replaced with the use of /dev/urandom - fixed the '/' separated arrays of words to work in both shells - fixed the way array elements are accessed (0-indexes in bash but 1-indexed in zsh) A comment has been added to the `PROMPT_COMMAND` example, wich only works in bash since the feature doesn't exist in zsh.
i manage to solve this by adding this line in the .zshrc file
instead of
|
This commit introduces several fixes to make sure the program works in bash and zsh - conditions use the correct [[]] syntax - the random generator has been replaced with the use of /dev/urandom - fixed the '/' separated arrays of words to work in both shells - fixed the way array elements are accessed (0-indexes in bash but 1-indexed in zsh) The PROMPT_COMMAND in the readme has been updated to provide a working example with zsh (@AlonsoCGonzaled suggestion) @mja00 suggested using the LC_CTYPE=C variable for the random generator to ensure compatibility with MacOS
Negative responses don't seem to work with this |
Did you resolve it?. that line worked for me. |
Positive responses work, but not negative |
I tried fixing it using ChatGPT since it's so small for the lols big surprise it didn't work
|
made a small (but awful) workaround that works, at least for me; try: . /path/to/shell-mommy.sh
precmd() { if (( $? == 0 )); then; echo $(success); else; echo $(failure); fi }
mommy in .zshrc; only issue is that it echoes twice at zsh's startup |
Been getting a fair bit of attention regarding zsh compatibility. I honestly haven't, and please don't rake me over the coals for this, cared enough about it to put in a ton of effort into fixing it. So far each proposed thing that's been submitted seems to have some kind of issue with it, and my unfamiliarity with zsh means I'm not likely to be able to debug it myself. So I'm kinda waiting for you guys to reach consensus on what works. Thanks~ edit: my opinion on adding zsh support has improved slightly as a coworker has informed me that it is now the default shell in macOS. can't leave the folks using mac out! |
https://gitlab.com/dwt1/bash-insulter from Derek Taylor does simmilar things and has support for other shells, maybe you guys can figure something out from this repo |
I tried this but I get weird division by zero errors
This seems to happen for both positive and negative responses Edit: I made a dumb mistake and forgot to switch branches to the patched branch. NVM |
works for me on zsh with this pr #13 |
Same for me, I'm using this precmd instead of any others mentioned here though precmd() { if (( $? != 0 )); then; mommy false; fi } this only gives a mommy invocation if my command failed (like |
Can use precmd() { if (( $? != 0 )); then; mommy false; else; mommy true; fi } for positive as well |
You can also use Not sure how exactly to integrate it with sudofox' version of mommy, but I recently made my own version of mommy which you can integrate with zsh using the following settings: set -o PROMPT_SUBST
RPS1='$(mommy -1 -s $?)' Unfortunately, I couldn't find a way to get it working with colours, since my version uses (Alternatively, use |
If I remember rightly you can put ansi escape sequence in |
@Minion3665 Thanks for the tip! I implemented a nice workaround that works for zsh and will deploy it later today :-) (in the screenshot the font is intentionally super large so it's more HD) But I don't want to hijack this issue to be around my own program, so if anyone has further comments, suggestions, issues, etc. for my version of mommy, please visit the discussions for my version of mommy or check the issues for my version of mommy ^^ |
I don't want to bump this, and my purpose is not to advertise. But seeing these PR and issues, I just wanted to mention that I already had the similar plugin for ZSH. tuhanayim/zsh-mommy |
This issue is essentially redundant since the changes for POSIX compability. |
I can't seem to get this to work on zsh...
The text was updated successfully, but these errors were encountered: