Terminal error (some typo somewhere?) with .bashrc disables all aliases etc

Solution 1:

Looks like you have Windows line endings (\r\n) instead of Unix line endings (\n). For example, look at the first set of error messages:

... token `$'in\r''
'ash: /home/khaverim7/.bashrc: line 6: `case $- in

What it should be, if \r (carriage return, which sends the cursor back to the first character in a line) were printed as \r:

... token `$'in\r''
bash: /home/khaverim7/.bashrc: line 6: `case $- in\r'

Similarly,

: command not found

would be due the lone \r on an empty line:

bash: \r: command not found

And,

: invalid shell option name

would be due to a \r at the end of shopt command, where the option name is short enough:

bash: line 0: shopt: something\r: invalid shell option name

(Compare with bash -c blah and bash -c 'shopt -s blah'.)

To regain Unix line endings, use the dos2unix command to convert:

dos2unix .bashrc

I would suspect that you used a Windows-based client at some point (like WinSCP, FileZilla, etc.), or that your editor has defaulted to Windows line endings.