thefuck: Cannot run fuck in zsh without export errors

Installed via pip. Ran eval β€œ$(thefuck --alias)” in both bash and zsh. $ fuck then produces β€˜No fucks given’ in bash while in zsh it complains about invalid arguments.

$ eval "$(thefuck --alias)"
$ fuck
fuck:export:3: not valid in this context: -'
fuck:3: not an identifier: [skip

Also FWIW:

$ zsh --version
zsh 4.3.11 (x86_64-redhat-linux-gnu)
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.8 (Santiago)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15

Commits related to this issue

Most upvoted comments

it seems that was a issue of zsh.

when run export TF_SHELL_ALIASES=$(alias) in zsh, you can see the same error.

run unalias -- - and this error will disappear, but another error comes.

my way to deal with this problem is not use eval "$(thefuck --alias)" in ~/.zshrc

run thefuck --alias in your shell, delete the line which contain export TF_SHELL_ALIASES=$(alias), and write the output in your .zshrc

just like

fuck () {
    TF_PYTHONIOENCODING=$PYTHONIOENCODING;
    export TF_ALIAS=fuck;
    export TF_HISTORY="$(fc -ln -10)";
    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
}

It may not the best way to deal with this problem, but it really works.

So this is not an issue anymore since some 5.2 minor (?) version:

1b23d830ba7f# echo $ZSH_VERSION
5.2
1b23d830ba7f# zsh --version
zsh 5.2 (x86_64-alpine-linux-musl)
1b23d830ba7f# unalias -m '*'
1b23d830ba7f# alias
1b23d830ba7f# alias ll='ls -a'
1b23d830ba7f# alias
ll='ls -a'
1b23d830ba7f# foo=$(alias)
1b23d830ba7f# export foo=$(alias)
1b23d830ba7f# export foo="$(alias)"
1b23d830ba7f# print $foo
ll='ls -a'

Zsh 5.2 was released almost 3 years ago.

The question now is: should we support old versions?

Please cast your vote with either πŸ‘ or πŸ‘Ž reaction to this very message:

image

Thanks!

@scorphus Thefuck works fine on Ubuntu with zsh, but I met the above problem on mac.