From ArchWiki

The Fuck is a magnificent app, that corrects errors in previous console commands.


Install thefuck package.


Configuration required to use thefuck.


Add this alias to ~/.bashrc:

eval "$(thefuck --alias)"


Add this alias to ~/.zshrc:

eval "$(thefuck --alias)"


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/ 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/



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


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


To fix the the previous command, use the fuck command.

To run fixed commands without confirmation, use the --yeah option (or just -y for short, or --hard if you're especially frustrated):

fuck --yeah

To fix commands recursively until succeeding, use the -r option:

fuck -r


If the following error message is shown when trying to run thefuck:

command not found: thefuck

Ensure that ~/.local/bin is present in your path. eg. add PATH="$PATH:$HOME/.local/bin" to ~/.bashrc, ~/.zshrc etc.

Tips and tricks

Experimental instant mode

The default behavior of The Fuck requires time to re-run previous commands. When in instant mode, The Fuck saves time by logging output with script, then reading the log.

Currently, instant mode only supports Python 3 with bash or zsh. zsh's autocorrect function also needs to be disabled in order for thefuck to work properly.

To enable instant mode, add --enable-experimental-instant-mode to the alias initialization in ~/.bashrc, ~/.bash_profile or ~/.zshrc.

For example:

eval $(thefuck --alias --enable-experimental-instant-mode)

See also