.bashrc (line 6): $- is not a valid variable in fish

I have had garuda for a couple days. I went to my .bashrc file to set an alias and when I did the command source .bashrc it returned the error:

.bashrc (line 6): $- is not a valid variable in fish.
[[ $- != *i* ]] && return
^
from sourcing file .bashrc
source: Error while reading file “.bashrc”

I didn't find any solution online so I just went around trying things such as messing with quotation marks and trying things similar to:

if $status != 0 
    then return

and got an error saying 0 isn't a command

Links that I found most helpful when trying to get a solution:
https://fishshell.com/docs/current/fish_for_bash_users.html#

https://wiki.archlinux.org/title/fish#Setting_fish_as_interactive_shell_only

Also a side note, I am fairly incompetent with linux so I may miss a fairly obvious solution.

You are using fish, you can't source a bash file.

What are you actually trying to do? Why are you sourcing that file?

3 Likes

Don’t you have to source the .bashrc file to update any changes made in it to take effect? I’ve done that before when making a recycle bin in centos for digital forensics purposes. Anyway though, isn’t the solution just to type bash in the terminal to switch to the bash shell and then source the .bashrc file and switch back to fish after?

Maybe if you are using bash...

No, that would load the stuff into your bash environment but it would likely be gone as soon as you exit the bash shell.

That is why I was trying to understand what the OP was actually trying to do.

1 Like

You can add the alias you want to use to your config.fish file.

micro .config/fish/config.fish

You will notice there are already quite a few in there (maybe even a few you didn't realize were there!). Feel free to add your own right into the file, or edit the ones there however you like.

If you make any egregious errors the whole config.fish file can be restored from the skeleton, so go wild. :wink:

5 Likes

I stated my purpose into the first line, sorry about not making it clear. I said "to set an alias", I was trying to add an alias to the .bashrc file but I got the error preventing the file from running after I sourced it. The intended result was for me to be able to use the alias from that .bashrc file. What the problem I was stating in the post was that I couldn't figure out how to re-write the .bashrc file so it would run.

My experience with linux could be put as minimal so my thought process may be very 1 dimensional... to you. Is there a file I should be adding my aliases or start-up commands to other than the bash file? I was under the impression that it was the file called when starting up a terminal, but that is starting to seem like a misunderstanding.

Ah, thank you. I see that it was because I simply lacked understanding.

Also, since the issue was not using the correct file, this is a repeat of this post (to a degree). I don't know how the forum mods handle this but this can be considered a duplicate.

When you use bash, that is how it works, yes. However, you aren't using bash. You are using fish

I believe for fish you would put the alias in ~/.config/fish/config.fish

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.