Thefuck: alias fuck="fuck -y" causes error when sourcing .zshrc

Created on 27 Mar 2020  路  6Comments  路  Source: nvbn/thefuck

  • The output of thefuck --version

The Fuck 3.30 using Python 3.8.2 and ZSH 5.8

  • My system:

macOS Catalina 10.15.4

  • How to reproduce the bug:

Update the .zshrc file. When I try to do a source ~/.zshrc I get the following error:

(eval):2: defining function based on alias `fuck'
(eval):2: parse error near `()'

The error is caused by eval "$(thefuck --alias)" line in the file. Note: When I for example open a new tab in the terminal after updating the config zsh initializes normally without errors.

  • The output of The Fuck with THEFUCK_DEBUG=true

Same as 鈽濓笍

Most helpful comment

@scorphus Exactly, that's what I wanted to write now. I renamed the issue to properly address the problem. And just to confirm the solution is:

eval $(thefuck --alias __fuck)
alias fuck="__fuck -y"

Thanks so much for helping out with this one!

All 6 comments

I could not reproduce the bug. What is the output of thefuck --alias? It should be as follows:

            fuck () {
                TF_PYTHONIOENCODING=$PYTHONIOENCODING;
                export TF_SHELL=zsh;
                export TF_ALIAS=fuck;
                TF_SHELL_ALIASES=$(alias);
                export TF_SHELL_ALIASES;
                TF_HISTORY="$(fc -ln -10)";
                export TF_HISTORY;
                export PYTHONIOENCODING=utf-8;
                TF_CMD=$(
                    thefuck THEFUCK_ARGUMENT_PLACEHOLDER $@
                ) && eval $TF_CMD;
                unset TF_HISTORY;
                export PYTHONIOENCODING=$TF_PYTHONIOENCODING;
                test -n "$TF_CMD" && print -s $TF_CMD
            }

Yes It's exactly like that. I found what was causing the error. Below that in the config I had this alias fuck="fuck -y" And that was causing the problem 馃檮 My bad. Is there a proper way to alias fuck to fuck -y?

Glad you found the issue \o/

How about:

john@host ~ % grep fuck .zshrc
eval $(thefuck --alias __fuck)
alias fuck="__fuck -y"
john@host ~ % echoo ok
zsh: command not found: echoo
john@host ~ % fuck
echo ok
ok
john@host ~ % 

Sorry, I closed the issue accidentally (cmd+shift+enter 鈥撀營 thought I was in vscode 馃お)

[edit]removed misleading replies I made[/edit]

Ah, .zshrc can only be source鈥檇 when the function is defined as __fuck and the alias uses it 鈥撀燼.k.a. my first suggestion.

@scorphus Exactly, that's what I wanted to write now. I renamed the issue to properly address the problem. And just to confirm the solution is:

eval $(thefuck --alias __fuck)
alias fuck="__fuck -y"

Thanks so much for helping out with this one!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

disjunto picture disjunto  路  6Comments

whereistejas picture whereistejas  路  4Comments

radjivF picture radjivF  路  4Comments

jabbson picture jabbson  路  4Comments

jedwards1211 picture jedwards1211  路  4Comments