Automatically generated fish config produces errors

i recently set up fish, and now it says that there is an error in the file ~/.config/fish/config.fish. i also cant edit the file. this error appeared first when i moved my custom shell init script into a seperate file. what can i do?

Could you share the actual error, and whatever nixos config you have for fish and for the generic shell options?

I don’t think that file is generated (neither by NixOS nor fish). At best, it’s written out on the first run with this content:

if status is-interactive
    # Commands to run in interactive sessions can go here
end

the output is:

~/.config/fish/config.fish (line 19): Missing end to balance this begin
status is-interactive; and begin
                           ^~~~^
from sourcing file ~/.config/fish/config.fish
	called during startup
source: Error while reading file '/home/noof/.config/fish/config.fish'
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
noof@nixos ~>

~/.config/fish/config.fish:

# ~/.config/fish/config.fish: DO NOT EDIT -- this file has been generated
# automatically by home-manager.

# Only execute this file once per shell.
set -q __fish_home_manager_config_sourced; and exit
set -g __fish_home_manager_config_sourced 1

source /nix/store/nc44iby2jrshk9ka13pq8z1mcjg7xraa-hm-session-vars.fish



status is-login; and begin

    # Login shell initialisation


end

status is-interactive; and begin

    # Abbreviations


    # Aliases


    # Interactive shell initialisation
    set fish_greeting
    function fish_prompt
        printf "(%s%s%s) %s%s%s\n" (set_color green) $USER (set_color normal) (set_color blue) (prompt_pwd) (set_color normal)
        set locstatus $status
        if test $locstatus != 0
            printf " %s[%s]%s" (set_color red) $locstatus (set_color normal)
        end
        printf " ⊂ "

        # add completions generated by Home Manager to $fish_complete_path
        begin
            set -l joined (string join " " $fish_complete_path)
            set -l prev_joined (string replace --regex "[^\s]*generated_completions.*" "" $joined)
            set -l post_joined (string replace $prev_joined "" $joined)
            set -l prev (string split " " (string trim $prev_joined))
            set -l post (string split " " (string trim $post_joined))
            set fish_complete_path $prev "/home/noof/.local/share/fish/home-manager_generated_completions" $post
        end


    end

Ah, you’re using home-manager. Indeed it looks like a final line with end is missing.
Have you tried rebuilding the home, yet?

yes, i did. doesnt change anything.

oh, solved it. forgot a end in my init script…

1 Like