Thefuck: How to install it on Windows?

Created on 21 Jul 2015  路  22Comments  路  Source: nvbn/thefuck

I'm using Windows 7
I installed successfully python 3.4.3 and "the fuck" package by using "pip install thefuck" on command line
However, I don't know how to apply "the fuck" for my Git Bash (located at "C:\Program Files\Git\bin\sh.exe")

windows

Most helpful comment

Cmder (and by extension, clink) does keep a history file. Clink also provides tail and head commands. So, with some really janky trickery, I was able to make thefuck work on Windows with Cmder.

  1. Run clink set history_io 1 and restart your shell. By default clink only writes history on exit, this ensures it writes as commands are run.
  2. Place this file somewhere in your path: https://gist.github.com/OfficerHalf/a9848df0a25706532f86dc8aaae56e4f
  3. Run alias fuck=thefuckcmder

If you only want to use clink, not Cmder, you can replace all the %CMDER_ROOT% paths with %LOCALAPPDATA%\clink\.history

I'm sure there's a better way to do this, I'm just not sure what it is. ctrl+c also crashes the whole thing, and colors in the console seem to get funky.

Essentially that batch file:

  1. Writes the last command run (before fuck) to a temporary file by getting the 2nd to last line of the history file.
  2. Sets fucked_cmd to the content of that file
  3. Runs thefuck %fucked_cmd%, and saves the output to a second temporary file, this time a .cmd file.
  4. Calls that .cmd file

I don't do a whole lot of batch stuff, so if someone can condense that, be my guest.

All 22 comments

Thanks for your support @bugaevc . I reached it!

Then close the issue :)

So, what was the solution?

The solution is to put the usual thing (eval "$(thefuck-alias)") into .bashrc file. The problem was to find that file on Windows, and the StackOverflow answers suggest that it's C:\Users\<your user name>\.bashrc

Ok thanks! I need to figure out how to use a .bashrc file with Cmder now ;)

Are you sure it's bash-compatible?

I have no idea, I will ask there. I can keep you informed in this issue if you want.

Send me my videos

Cmder does not use a .bashrc file. Cmder by default is still the Windows command line. What you can do, is open up Cygwin using Cmder, as described here: https://github.com/cmderdev/cmder/wiki/%5BWindows%5D-Integrating-Cygwin

I did the same as said in the 2 links (created a .bashrc file, added thefuck alias in it, saved it and used it as source). But it still does not seem to work. I type thefuck and it shows usage help, I type fuck and it says no fucks given. But typing a wrong command still only says bash: __ command not found. What did I miss?

Cmder (and by extension, clink) does keep a history file. Clink also provides tail and head commands. So, with some really janky trickery, I was able to make thefuck work on Windows with Cmder.

  1. Run clink set history_io 1 and restart your shell. By default clink only writes history on exit, this ensures it writes as commands are run.
  2. Place this file somewhere in your path: https://gist.github.com/OfficerHalf/a9848df0a25706532f86dc8aaae56e4f
  3. Run alias fuck=thefuckcmder

If you only want to use clink, not Cmder, you can replace all the %CMDER_ROOT% paths with %LOCALAPPDATA%\clink\.history

I'm sure there's a better way to do this, I'm just not sure what it is. ctrl+c also crashes the whole thing, and colors in the console seem to get funky.

Essentially that batch file:

  1. Writes the last command run (before fuck) to a temporary file by getting the 2nd to last line of the history file.
  2. Sets fucked_cmd to the content of that file
  3. Runs thefuck %fucked_cmd%, and saves the output to a second temporary file, this time a .cmd file.
  4. Calls that .cmd file

I don't do a whole lot of batch stuff, so if someone can condense that, be my guest.

does it still work for you? @OfficerHalf

Maybe, haven't actually tried it in a while. It should be the same, but look here: http://nathan-smith.org/blog/using-thefuck-with-clink-cmder

I actually already did that :D
I still don't get it to work, though.

When running cmder normally:

C:\Users\
位 fuck
*Access denied

When running cmder as admin:

C:\Users\
位 fuck
tail: cannot open 'Files\cmder\config\.history'head for reading::  No such file or directorycannot open
'Files\cmder\config\fucked_cmd.txt' for reading: No such file or directory
Files\cmder\config\fucked_cmd.txtNo fucks given
*The command "C:\Program" is either misspelled or could not be found.

*: translated

Looks like an issue with spaces in your path to cmder - see how it split up Program and Files?

Yes! But how to resolve this?
I've tried setting CMDER_ROOT to %programfiles%\cmder which didn't change anything..

Cannot get it to work on Windows 10, Git Bash. My .bashrc looks as follows:

alias thefuck="/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/Shared/Python36\_64/Scripts/fuck"
eval $(thefuck --alias)

Do you have any insights on how to set this up? Please bear in mind that I am not very familiar with setting up variables on Windows, so I may have made some obvious mistake there.

@bariod, maybe this can help?
https://gist.github.com/OfficerHalf/a9848df0a25706532f86dc8aaae56e4f#gistcomment-2857119

This doesn't seem to have helped much. Thanks for your input, but I cba to investigate this any further :D

Yeah, I'm sorry. I no longer use thefuck, so I can't really be of much help here. The general idea is just that you need to get access to your command history somehow, get the failed command somehow, and then pass it to thefuck.

I'm using Windows 7
I installed successfully python 3.4.3 and "the fuck" package by using "pip install thefuck" on command line
However, I don't know how to apply "the fuck" for my Git Bash (located at "C:\Program Files\Git\bin\sh.exe")

  1. open git bash, in git bash run the following
  2. python -m pip install thefuck
  3. eval "$(thefuck -alias)"
  4. cd ~, find the name of current dir after doing ~
  5. download .bashrc file from https://github.com/BenjaminLiuPenrose/thefuck/blob/my_change/thefuck/.bashrc under dir

    you should be fine then

Was this page helpful?
0 / 5 - 0 ratings