• Uncategorized

About node.js : if-statement-error-while-running-source-bashrc-error

Question Detail

I tried running source ~/.bashrc but it shows

~/.bashrc (line 5): Missing end to balance this if statement
if  [ -x /usr/bin/starship ]; then
from sourcing file ~/.bashrc
source: Error while reading file “/home/alokjha/.bashrc”

How do i solve it?

I am currently on Garuda Linux (arch linux distro) and new in this linux universe, I want to install nvm, i followed steps as written in https://github.com/nvm-sh/nvm. I am not familiar with bash language so kindly help please ( Restart PC or Terminal is’t helping)

Edit: Complete BashRc file

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

# Load starship prompt if starship is installed
if  [ -x /usr/bin/starship ]; then
    __main() {
        local major="${BASH_VERSINFO[0]}"
        local minor="${BASH_VERSINFO[1]}"

        if ((major > 4)) || { ((major == 4)) && ((minor >= 1)); }; then
            source <("/usr/bin/starship" init bash --print-full-init)
            source /dev/stdin <<<"$("/usr/bin/starship" init bash --print-full-init)"
    unset -f __main

# Advanced command-not-found hook
source /usr/share/doc/find-the-command/ftc.bash

# Aliasessource ~/.bashrc error
alias dir='dir --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias fixpacman="sudo rm /var/lib/pacman/db.lck"
alias grep='grep --color=auto'
alias grubup="sudo update-grub"
alias hw='hwinfo --short'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
alias psmem='ps auxf | sort -nr -k 4'
alias rmpkg="sudo pacman -Rdd"
alias tarnow='tar -acf '
alias untar='tar -zxvf '
alias upd='/usr/bin/update'
alias vdir='vdir --color=auto'
alias wget='wget -c '

# Help people new to Arch
alias apt-get='man pacman'
alias apt='man pacman'
alias helpme='cht.sh --shell'
alias please='sudo'
alias tb='nc termbin.com 9999'

# Cleanup orphaned packages
alias cleanup='sudo pacman -Rns `pacman -Qtdq`'

# Get the error messages from journalctl
alias jctl="journalctl -p 3 -xb"

# Recent installed packages
alias rip="expac --timefmt='%Y-%m-%d %T' '%l\t%n %v' | sort | tail -200 | nl"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Question Answer

I ran into the same problem.
First I want to make it clear that I am a newbie in Arch and Garuda, so maybe some of my statements are not entirely correct.

Just as someone told you in the comments, you are using fish, look at the title of the Konsole window. Or edit the .bashrc file and set the if to fish syntax (change fi to end) and you’ll see that the next error tells you clearly that you are using fish.

Quick “fix”

Switch to bash by running bash, then you can run source ~/.bashrc.

The problem with this is that if you exit bash (by executing exit) and return to fish, you lose what you get by executing source ~/.bashrc. I mean, you have to keep working in bash.

Solutions without switching to bash

Use nvm.fish.

Or convert the lines you need (the last 3 of your bashrc file) to fish syntax, and add them to the ~/.config/fish/config.fish file, then run source ~/.config/fish/config.fish.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.