How to install it on Windows?
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")
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
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.
- Run
clink set history_io 1and restart your shell. By default clink only writes history on exit, this ensures it writes as commands are run. - Place this file somewhere in your path: https://gist.github.com/OfficerHalf/a9848df0a25706532f86dc8aaae56e4f
- 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:
- Writes the last command run (before
fuck) to a temporary file by getting the 2nd to last line of the history file. - Sets
fucked_cmdto the content of that file - Runs
thefuck %fucked_cmd%, and saves the output to a second temporary file, this time a.cmdfile. - Calls that
.cmdfile
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..
@bariod, maybe this can help? https://gist.github.com/OfficerHalf/a9848df0a25706532f86dc8aaae56e4f#gistcomment-2857119
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")
- open git bash, in git bash run the following
- python -m pip install thefuck
- eval "$(thefuck -alias)"
- cd ~, find the name of current
dirafter doing ~ - download .bashrc file from
https://github.com/BenjaminLiuPenrose/thefuck/blob/my_change/thefuck/.bashrcunderdir
you should be fine then
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")
- open git bash, in git bash run the following
- python -m pip install thefuck
- eval "$(thefuck -alias)"
- cd ~, find the name of current
dirafter doing ~- download .bashrc file from
https://github.com/BenjaminLiuPenrose/thefuck/blob/my_change/thefuck/.bashrcunderdiryou should be fine then
I follow your step but still not working. Tested via both VSCode and CMD
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