thefuck icon indicating copy to clipboard operation
thefuck copied to clipboard

How to install it on Windows?

Open phieudu241 opened this issue 10 years ago • 24 comments

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")

phieudu241 avatar Jul 21 '15 10:07 phieudu241

http://stackoverflow.com/questions/6883760/git-for-windows-bashrc-or-equivalent-config-files-for-git-bash-shell http://superuser.com/questions/602872/how-do-i-modify-my-git-bash-profile-in-windows

bugaevc avatar Jul 21 '15 15:07 bugaevc

Thanks for your support @bugaevc . I reached it!

phieudu241 avatar Jul 22 '15 02:07 phieudu241

Then close the issue :)

bugaevc avatar Jul 22 '15 16:07 bugaevc

So, what was the solution?

ClementParis016 avatar Jul 30 '15 08:07 ClementParis016

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

bugaevc avatar Jul 30 '15 08:07 bugaevc

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

ClementParis016 avatar Jul 30 '15 10:07 ClementParis016

Are you sure it's bash-compatible?

bugaevc avatar Jul 30 '15 13:07 bugaevc

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

ClementParis016 avatar Jul 30 '15 18:07 ClementParis016

Send me my videos

brittneybrinsfield avatar Aug 23 '15 13:08 brittneybrinsfield

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

DanielGGordon avatar Oct 08 '15 21:10 DanielGGordon

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?

goddard-guryon avatar Jul 17 '18 12:07 goddard-guryon

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.

nathonius avatar Aug 10 '18 20:08 nathonius

does it still work for you? @OfficerHalf

bariod avatar Oct 30 '18 12:10 bariod

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

nathonius avatar Oct 30 '18 15:10 nathonius

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

bariod avatar Oct 31 '18 07:10 bariod

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

nathonius avatar Oct 31 '18 11:10 nathonius

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

bariod avatar Oct 31 '18 11:10 bariod

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

zionyx avatar Mar 08 '19 10:03 zionyx

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.

AlexanderHess avatar Mar 27 '19 09:03 AlexanderHess

@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

bariod avatar Apr 05 '19 09:04 bariod

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.

nathonius avatar Apr 18 '19 18:04 nathonius

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

BenjaminLiuPenrose avatar Mar 31 '20 22:03 BenjaminLiuPenrose

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

I follow your step but still not working. Tested via both VSCode and CMD

yasirroni avatar Oct 08 '22 09:10 yasirroni

Hi !

I've experienced the same problem, I've got a Mac and installed the package and edited the bashrc and it's working well. But on my computer with Windows 11 installed,it's impossible to get the command working on bash terminal using vscode.

I've installed the package using pip, edited the bashrc on the current path C:/user/myusername/ and impossible to get the command working "bash: fuck: command not found" everytime, anyone knows how to get this working in my case please :) ?

PS: I've tried to delete bash_profile and when i've restarted vscode the terminal displayed an error saying that he was finding a bashrc without a bash_profile file and he recreated it, so i think vscode is running the bashrc file while launching but still doesn't know why he can't find the command

florianzemma avatar Dec 22 '22 18:12 florianzemma