# How can I make fish my default shell (without a nest of shells)?

**URL:** <https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949>\
**Category:** Help\
**Created:** [August 26, 2024, 9:02pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949 "2024-08-26T21:02:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lofidevops](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/lofidevops/32/682_2.png) [@lofidevops](https://discourse.flox.dev/u/lofidevops)\
**Post date:** [August 26, 2024, 9:02pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949/1 "2024-08-26T21:02:13Z")

</div>

After some head-scratching I now have flox running by default in my Ubuntu terminal. Previously I had fish (installed via apt) as my default shell and this seemed to cause problems. To resolve this I:

- uninstalled fish from Ubuntu
- reset my default shell to bash
- created a default flox environment
- added `flox activate` to `.bashrc`

I have also run `flox install fish` in my default environment so `which fish` returns:

```auto
/home/user/.cache/.../bin/fish

```

And I can manually run `fish` to launch the fish shell. Now I want to make fish my default flox shell.

According to [Is it possible to set a different default shell?](https://discourse.flox.dev/t/is-it-possible-to-set-a-different-default-shell/656) I should be able to update my `.bashrc` activation command. The following change does _something_:

```auto
eval "$(FLOX_SHELL=fish flox activate -r my/default)"

```

but it fails. As far as I can tell this is because bash is trying to parse a fish script:

```auto
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: /home/user/.cache/.../activate.d/fish: line 39: syntax error near unexpected token `if'
bash: /home/user/.cache/.../activate.d/fish: line 39: ` if test -e "$FLOX_ENV/activate.d/$i"'

```

I am also concerned that setting my default shell this way means I am creating a nightmare nest of processes:

```plaintext
bash > flox > bash > ??? > fish

```

What is the sensible way to make fish, as defined by flox, my default shell?

---

<div class="post-metadata">

**Author:** ![ghudgins](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ghudgins/32/588_2.png) [@ghudgins](https://discourse.flox.dev/u/ghudgins)\
**Post date:** [August 28, 2024, 5:37pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949/2 "2024-08-28T17:37:15Z")

</div>

similar to the other post, are you able to upgrade to 3.7.1?

---

<div class="post-metadata">

**Author:** ![lofidevops](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/lofidevops/32/682_2.png) [@lofidevops](https://discourse.flox.dev/u/lofidevops)\
**Post date:** [August 28, 2024, 6:37pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949/4 "2024-08-28T18:37:23Z")

</div>

I follow up on that route in the other post. Although in this scenario, I wouldn’t bother installing fish on the base system and instead live in flox prompts powered by fish.

---

<div class="post-metadata">

**Author:** ![ysndr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ysndr/32/340_2.png) [@ysndr](https://discourse.flox.dev/u/ysndr)\
**Post date:** [September 3, 2024, 12:29pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949/5 "2024-09-03T12:29:31Z")

</div>

when running `$(flox activate)` flox will _output_ a script suitable for the executing shell or, as in this case, `FLOX_SHELL`.  
Effectively, `eval "$(FLOX_SHELL=fish flox activate -r my/default)"` in a bash shell, will result in flox outputting a fish script which is then evaluated by `bash`s `eval` i.e. as a bash script.  
Since both shell dialects are not compatible you get bash errors.

I guess you could run something like `FLOX_SHELL=fish exec flox activate -r my/default` as the last thing in your bashrc. that would at least get you out of the nesting

~~bash~~ \> ~~flox~~ \> fish

Whether one _should_ do this is another question, considering the side effects that would have on other uses of bash expecting bashrcs to leave you in a bash shell…

---

<div class="post-metadata">

**Author:** ![lofidevops](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/lofidevops/32/682_2.png) [@lofidevops](https://discourse.flox.dev/u/lofidevops)\
**Post date:** [September 4, 2024, 7:04pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949/6 "2024-09-04T19:04:26Z")

</div>

> Whether one _should_ do this is another question

Indeed. I also ran into “The file specified the interpreter ‘/bin/fish’, which is not an executable command.” when trying to run a fish script, since `/bin/fish` no longer exists. I think I will leave this question of bootstrapping fish within flox for another day, and just use the system-provided version of fish.

---

<div class="post-metadata">

**Author:** ![lofidevops](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/lofidevops/32/682_2.png) [@lofidevops](https://discourse.flox.dev/u/lofidevops)\
**Post date:** [September 5, 2024, 8:07pm UTC](https://discourse.flox.dev/t/how-can-i-make-fish-my-default-shell-without-a-nest-of-shells/949/7 "2024-09-05T20:07:02Z")

</div>

I now have this working with system-installed fish and a simple change to `config.fish`. Full details…

- Install fish 3.7.1 or higher (on Ubuntu, use the [fish shell PPA](https://launchpad.net/~fish-shell/+archive/ubuntu/release-3))
- Install flox
- `chsh` to set fish as the default shell
- Create [default flox environment](https://flox.dev/docs/tutorials/layering-multiple-environments/)

Now whenever you launch a terminal, you should be in fish, and you should be able to run `flox activate`. To make it automatic, add the following line to `$HOME/.config/fish/config.fish`:

```auto
eval (flox activate --dir=$HOME) | source

```

Now whenever you launch a terminal, you should be in fish and your default environment should be activated (run `flox list` to confirm). And you can install all other tools with flox.

Also confirmed in `gnome-system-monitor` that I don’t have a chain of shells.
