Un-auto-complete Terminal
Solution 1:
According to the bash man page, the default shortcut for the undo
function is either Ctrl+_ (note that this is Ctrl+Shift+- on most keyboards) or Ctrl+x followed by Ctrl+u. If your tab completion added a trailing slash to the directory name, you may have to undo twice, once to remove the slash and once more to remove the text that the completion added.
If instead what you want is to remove the last complete directory component from a path you are entering in bash, the closest way to achieve this is with the backward-kill-word
function. By default this is bound to the Alt+Backspace key combination. This will erase the last "word" from your command line, where a word consists entirely of alphanumeric characters.
This seems to work with your given example directory names. Note that if the last directory name contains spaces or punctuation characters like -
or _
, these are treated as word delimiters, so you may have to repeat this key combination more than once to erase back to the last /
character.
Solution 2:
Use Zsh, with oh-my-zsh (optional)
press control and c or if you want maybe a better way, press control + shift + underscore key. Sorry I don't use bash, zsh is superior anyway, give it a try