Sourcing .bashrc Error

Hi, I’ve been using CachyOS on a VM for a little while now and really enjoy using the OS. I was recently going to add something to my .bashrc file, however I noticed that when I try to source .bashrc I get the following error:

.bashrc (line 11): “case” builtin not inside of switch block

I have not changed anything in the .bashrc file prior to this point so I’m not exactly sure why I am getting the error and if this is something with me or just the OS. I tried restoring .bashrc from the copy in /etc/skel just in case something did get changed, but the problem still persists. I’m thinking this is probably just me being stupid, but any help or suggestions that anyone could provide would be much appreciated. I have included the contents of my .bashrc file below, thank you.

# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

# Change the window title of X terminals
case ${TERM} in
    xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
        ;;
    screen*)
        PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
        ;;
esac

alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -la'
alias l='ls'
alias l.="ls -A | egrep '^\.'"
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'
alias df='df -h'                          # human-readable sizes
alias free='free -m'                      # show sizes in MB
PS1='[\u@\h \W]\$ '

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

shopt -s expand_aliases

# export QT_SELECT=4

# Enable history appending instead of overwriting.  #139609
shopt -s histappend

#neofetch
. "$HOME/.cargo/env"```

So let me ask this. When you run the source command, are you running it under bash shell when you run it? try running the command bash first, than try sourcing it. when you type bash, it will switch to the bash shell. if you run source under bash it should work.
The problem you are facing might be due to the fact that you might be running the source command under fish, which won’t work.

What is your default shell?

echo $SHELL

Because my default shell (in CachyOS) is fish.

1 Like

Yeah that’s it, just assumed it would work with fish, stupid mistake. Thanks for your help!

1 Like

Yeah, that was the issue. Was using fish, should have been using bash.