Skip to content
Leonardo Valeri Manera edited this page Jul 22, 2024 · 33 revisions

Bash

Add this alias to .bashrc or .bash_profile (for OSX):

eval "$(thefuck --alias)"

To overcome Python unicode warning on your unicode Windows Git-Bash console:

C:\Dev\Python\Lib\site-packages\win_unicode_console\__init__.py:31: RuntimeWarning: sys.stdin.encoding == 'utf-8', whereas sys.stdout.encoding == 'cp1252', readline hook consumer may assume they are the same
  readline_hook.enable(use_pyreadline=use_pyreadline)

Add this line before the line above in your ~/.bashrc on Windows:

export PYTHONIOENCODING="utf-8"

ZSH

Add this alias to .zshrc:

eval "$(thefuck --alias)"

If you use oh-my-zsh, try this awesome thefuck plugin.

Fish

Add this function to config.fish:

thefuck --alias | source 

To avoid the delay of the shell startup, you could also create an autoloaded function. Create a file ~/.config/fish/functions/fuck.fish instead and paste the output of thefuck --alias into that file. Fish should start as fast as before.

For cases when you override a command and turn it into an alias (e.g. alias sed=gsed or alias git=hub), you should add all them to the THEFUCK_OVERRIDDEN_ALIASES environment variable, separated by comma. For example, in your config.fish:

set -x THEFUCK_OVERRIDDEN_ALIASES 'gsed,git'

Powershell

Put this in your Powershell $PROFILE on Windows:

iex "$(thefuck --alias)"

To overcome Python unicode warning on your unicode Powershell console:

c:\python3\lib\site-packages\win_unicode_console\__init__.py:31: RuntimeWarning: sys.stdin.encoding == 'utf-8', whereas sys.stdout.encoding == 'ascii', readline hook consumer may assume they are the same
  readline_hook.enable(use_pyreadline=use_pyreadline)

Add this line before the line above in your Powershell $PROFILE on Windows:

$env:PYTHONIOENCODING="utf-8"

To overcome PowerShell not running scripts, for which the error looks as such:

. : File C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 cannot be loaded because running scripts is disabled
on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3

You could set execution policy to unrestricted through the PowerShell command:

Set-ExecutionPolicy unrestricted

Click here to read more about Microsoft's execution policies.

tcsh

alias fuck 'set fucked_cmd=`history -h 2 | head -n 1` && eval `thefuck ${fucked_cmd}`'

xonsh

Install the xonsh extension:

pip install xontrib-thefuck

And then load it (you can add this to xonshrc for it to be loaded in every xonsh session):

xontrib load thefuck

wsl

in wsl you may also have to put export PATH="$PATH:~/.local/bin/" before the alias

export PATH="$PATH:~/.local/bin/"
eval $(thefuck --alias fuck)

Hilbish

Make sure you import the commander library:

local commander = require 'commander'

hilbish.history.get(hilbish.history.size() - 1) will load the last typed command so you can put it into an alias here:

commander.register("fuck", function()
  os.execute("thefuck " .. hilbish.history.get(hilbish.history.size() - 1))
end)

Nushell

Add this alias to your config.nu:

alias fuck = thefuck $"(history | last 1 | get command | get 0)"

wda

Clone this wiki locally