3

Way back while studying I used tcsh as my main shell and it had this nifty feature of being able to correct a misspelled command name by pressing Escape-$ which would the. change eg “bsah” to “bash”

Now I needed it (apparently kustomize is not keyboard friendly) but could not recall ever having seen this in bash.

Can bash do this and if so how?

5
  • The only other shell (that I'm aware of) that offers correction of mistyped command names is zsh, with its CORRECT shell option set.
    – Kusalananda
    Commented May 19, 2023 at 15:02
  • With shopt -s dirspell cdspell, you can get bash to correct directory names on pathname completions and cd commands respectively, but specifically spell-checking command names does not seem to be available in it.
    – telcoM
    Commented May 19, 2023 at 15:09
  • FWIW, M-$ also works in zsh (in emacs mode, spell-word widget). Any particular reason to choose bash? Seems an odd choice to me especially when coming from tcsh. See also the dvorak option in case you're using a dvorak keyboards so the spelling corrections are tuned to that keyboard layout, and the correct and correctall opionts for the auto-correct (like tcsh's correct variable) Commented May 19, 2023 at 15:31
  • @Kusalananda I don't particular care about which sh-dialect I use as long as it can edit current line properly, and has a history to pick from (and preferably is supported by kubectl completion ..). As my personal Mac has long since switched to zsh I might give it a try here too. Commented May 20, 2023 at 11:11
  • @StéphaneChazelas I typically only use a system a short while before installing a new, and bash is the default on Ubuntu which I like. Now I have a long lived system and can tune it more. Commented May 21, 2023 at 18:48

2 Answers 2

1

To my knowledge in bash, there is no direct equivalent to the M-$ feature in tcsh for correcting misspelled command names.

Bash offers some useful features like:

  • tab completion
  • command history
  • command editing

These can help you to correct misspelled command names or navigate through previous commands effectively in Bash.

It doesn't offer the exact functionality of M-$ in tcsh, but these features should be helpful.

2
  • gnu.org/software/bash/manual/bash.html
    – Z0OM
    Commented May 19, 2023 at 14:30
  • 1
    Thanks. I have used bash for many years so I knew most of these things. Problem is that the manual is so large that unless you know exactly what it is called what you are looking for, it can be rather hard to find. Commented May 20, 2023 at 11:16
-5

Hit Arrow Up and edit the command however you like.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .