Thefuck: fish can not config thefuck

Created on 8 Nov 2017  路  2Comments  路  Source: nvbn/thefuck

I add "thefuck --alias | source" into my /etc/fish/config.fish
which is

#
# Init file for fish
#

#
# Some things should only be done for login terminals
#

if status --is-login

    #
    # Set some value for LANG if nothing was set before, and this is a
    # login shell.
    #

    if not set -q LANG >/dev/null
        set -gx LANG en_US.UTF-8
    end

    # Check for i18n information in
    # /etc/sysconfig/i18n

    if test -f /etc/sysconfig/i18n
        eval (cat /etc/sysconfig/i18n |sed -ne 's/^\([a-zA-Z]*\)=\(.*\)$/set -gx \1 \2;/p')
    end

    #
    # Put linux consoles in unicode mode.
    #

    if test "$TERM" = linux
        if expr "$LANG" : ".*\.[Uu][Tt][Ff].*" >/dev/null
            if which unicode_start >/dev/null
                unicode_start
            end
        end
    end
end
thefuck --alias | source

but when I turn to my fish I got this

Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.
- (line 10):                 ) && eval $TF_CMD;
                                ^
from sourcing file -
    called on line 39 of file /etc/fish/config.fish

from sourcing file /etc/fish/config.fish
    called during startup

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

how can I fix it ?

Most helpful comment

Just use the following function instead of '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

The reason you get this error is because your 'SHELL' environment variable still is bash instead of fish so this program things you're on bash and thus outputs a shell script for bash instead of fish.

All 2 comments

Just use the following function instead of '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

The reason you get this error is because your 'SHELL' environment variable still is bash instead of fish so this program things you're on bash and thus outputs a shell script for bash instead of fish.

I fix this error with your code, you are really a nice guy, thx :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liuml07 picture liuml07  路  5Comments

yuanwenq picture yuanwenq  路  5Comments

lbenedetto picture lbenedetto  路  5Comments

zixuanweeei picture zixuanweeei  路  5Comments

caesar picture caesar  路  5Comments