Wednesday, May 8, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 4702  / 2 Years ago, fri, december 17, 2021, 9:47:27

If I mistype a command in Ubuntu shell, it offers a suggestion. Often, the suggestion is right, and I wish to use it. But there is no way except to repeat the last command and make the changes yourself. Why doesn't it offer a yes/no type suggestion, where you can simply type y to accept the suggestion? Any suggestions to enable such a behaviour?


Here's what happens:


user@user:/media/tux$ git stastus
git: 'stastus' is not a git command. See 'git --help'.

Did you mean this?
status
user@user:/media/tux$

More From » command-line

 Answers
5

The suggestion in your example isn't provided by Ubuntu's shell, but rather is part of the help.autocorrect feature built into Git itself.



There was discussion last year of adding an interactive "yes/no" prompt to Git, but some of the details were never decided upon so that work is still incomplete.



If you're looking for something to make this kind of suggestion for any command, you might like to try using the Z shell (zsh) instead of Bash. It offers general-purpose spelling correction for both commands and filenames, and provides an interactive prompt:



$ ehco hello > test.txt
zsh: correct 'ehco' to 'echo' [nyae]? y
$ cat tesst.txt
zsh: correct 'tesst.txt' to 'test.txt' [nyae]? y
hello


Changing shells isn't something to take lightly, though. By using any non-default shell you'll likely hit a few road bumps that will require time and effort to resolve.


[#29017] Sunday, December 19, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
azaaburge

Total Points: 266
Total Questions: 85
Total Answers: 109

Location: Djibouti
Member since Sat, Oct 29, 2022
2 Years ago
;