Comments (11)
There's a settings command_not_found
for path to command-not-found
.
from thefuck.
Are you suggesting that instead of a properly generic method, the correct path is instead simply using command-not-found
?
from thefuck.
I think this is related to #2 and #23
from thefuck.
@skyhighwings @nvbn I found an implementation of command not found https://github.com/bfontaine/homebrew-command-not-found but it is not actually trying to correct command names but only suggesting to install packages you don't have if you write the right name.
from thefuck.
@academo yes, it is related to those :-)
I'd be willing to write a Levenshtein-based command finder later, but I don't know Python nearly as well as I do other languages.
from thefuck.
@skyhighwings I think you can write them in other languages and then run it into python I don't know python either.
from thefuck.
Ah ha! This is perhaps why it doesn't work on Arch Linux.
from thefuck.
@rperce that is precisely why it doesn't work on Arch, actually!
from thefuck.
I'd love to do this, but I won't be able to do it until this coming weekend. Lot's of work going on. If the timing is a problem let me know and somebody else can take it. A lot of the stuff below is based on @skyhighwings suggestions above
Heres the implementation I think would work best. Suggestions would be welcome:
- do a $PATH walk and store all executable binaries on a CSV file with a timestamp.
- include
alias
names in CSV list
- include
- on
fuck
, check if the timestamp is older than some config variable (default 7 days.) - if it is older, then rewalk the $PATH.
- if current, calculate the minimum Lavenstein distance from the CSV list of commands
- if, while running through the commands, the current minimum is 1 insertion/deletion/modification, then return that command
- either ask the user or just run the command
Also, there might be a more efficient way of calculating the best word for our purposes rather than using the Lavenstien distance, because running it on a list takes O(words*maxLength^2) which is pretty slow. Although that would be the most accurate, so if you chose another algorithm then it would be probably necessary to prompt the user and ask if the command should be run.
from thefuck.
@cdipaolo, cool idea, thanks. I've implemented something similar, but a bit simpler.
Should be crossplatform in 1.18+.
from thefuck.
👍
from thefuck.
Related Issues (20)
- Instant mode crashes KDE Plasma on login HOT 1
- Command intercepted but not presented a fuck, have to run fuck manually for the suggestion
- Command takes 6 seconds, then doesn't find the correction HOT 1
- Install error HOT 4
- no fucks given for git no tracking information for the current branch HOT 4
- Fetch sqlite fails when install with macos HOT 2
- [WARN] Output log isn't specified when "instant mode" turned on
- `<editor> <bash-path> +1 && puthon` suggestion instead of `python` HOT 4
- OpenSSL 1.1 End of Life HOT 4
- subprocess.run does not work inside side_effect
- ModuleNotFoundError: No module named 'imp' (python 3.12.0) HOT 3
- Not fully compatible with python 3.12.0 yet. HOT 1
- [Suggestion] Correct pip remove, delete to uninstall
- How about adding a typo correction rule related to 'nvm'?
- Request for adding Pull Request Template
- I can't run thefuck on powershell HOT 1
- Unhandled `apt` "Packages were downgraded and -y was used without --allow-downgrades" error
- Support for Windows CMD HOT 4
- /.zshrc:1: command not found: thefuck HOT 3
- Shell slow to start with `eval "$(thefuck --alias)"`, workaround is a lazy loading trick HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thefuck.