Thefuck: alias produces invalid code for fish as of 3.24

Created on 25 Oct 2017  路  6Comments  路  Source: nvbn/thefuck

As of 3.24 the output from thefuck --alias is incompatible with fish

Output from 3.24

$ thefuck --alias

            function fuck () {
                TF_PYTHONIOENCODING=$PYTHONIOENCODING;
                export TF_ALIAS=fuck;
                export TF_SHELL_ALIASES=$(alias);
                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;
                history -s $TF_CMD;
            }

$ thefuck --version                                                                                                                    
The Fuck 3.24 using Python 3.5.2

Output from 3.23

$ thefuck --alias
function fuck -d "Correct your previous console command"
  set -l fucked_up_command $history[1]
  env TF_ALIAS=fuck PYTHONIOENCODING=utf-8 thefuck $fucked_up_command | read -l unfucked_command
  if [ "$unfucked_command" != "" ]
    eval $unfucked_command
    builtin history delete --exact --case-sensitive -- $fucked_up_command
    builtin history merge ^ /dev/null
  end
end

$ thefuck --version                                                                                                                    
The Fuck 3.23 using Python 3.5.2

Fish version output

$ fish --version
fish, version 2.6.0

Most helpful comment

+1. My workaround is,

# In ~/.config/fish/config.fish
...
set -gx SHELL /usr/local/bin/fish # Add this line. Path of fish depends on your environment.
thefuck --alias | source
...

Probably the changes in the following line produce this problem.
https://github.com/nvbn/thefuck/blob/master/thefuck/shells/__init__.py#L53
This line check $SHELL at first. So, for example, if we don't use chsh, just run fish from bash, $SHELL still be /bin/bash, and thefuck generates the wrong alias.

All 6 comments

+1. Produces the same behavior for me with FISH 2.3.1 and The Fuck 3.24 on Python 3.6.2

+1. My workaround is,

# In ~/.config/fish/config.fish
...
set -gx SHELL /usr/local/bin/fish # Add this line. Path of fish depends on your environment.
thefuck --alias | source
...

Probably the changes in the following line produce this problem.
https://github.com/nvbn/thefuck/blob/master/thefuck/shells/__init__.py#L53
This line check $SHELL at first. So, for example, if we don't use chsh, just run fish from bash, $SHELL still be /bin/bash, and thefuck generates the wrong alias.

Thanks @kosukemori - glad you posted this! Spent way to much time trying to find a fix for this, this issue didn't appear in my search results.

I've found env SHELL=/usr/bin/fish thefuck --alias | source does pretty much the same thing

Fix is on its way! As in #738 and #744. Thanks @kosukemori for posting the workaround.

Fixed in 6290560

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuanwenq picture yuanwenq  路  5Comments

AlexWayfer picture AlexWayfer  路  4Comments

onewheelskyward picture onewheelskyward  路  3Comments

zixuanweeei picture zixuanweeei  路  5Comments

lbenedetto picture lbenedetto  路  5Comments