aboutsummaryrefslogtreecommitdiff
path: root/.config/fish/functions/create_fish_dotenv.fish
blob: 0574b535db5fc8eb1aad998130608f7db3d9d9c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function create_fish_dotenv
    if test -f .env
        echo "# Auto-generated .env.fish file" > .env.fish
        cat .env | while read line
            if not string match -qr '^\s*#' -q $line
                if not string match -qr '^\s*$' -q $line
                    set key (string split -m 1 '=' $line)[1]
                    set value (string split -m 1 '=' $line)[2]
                    echo "set -x $key $value" >> .env.fish
                end
            end
        end
        echo ".env.fish file created successfully."
    else
        echo ".env file not found in current directory."
    end
end