aboutsummaryrefslogtreecommitdiff
path: root/.config/fish/functions/load_dots.fish
blob: e9df84d1cee4bf6723f4416769c51cd3194a5e02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function load_dots
    set -l options git
    count $argv | read arg_count
    if test $arg_count -eq 0
        printf "options: "
        for arg in $options
            printf "$arg "
        end
        printf "\n"
    end
    for option in $argv
        switch "$option"
            case git
                load_git
            case \*
                printf "error: Unknown option %s\n" $option
        end
    end
end

function load_git
    git update-index --assume-unchanged .env
    envsource ~/.env | while read -l env_var
        switch $env_var
            case "GIT_*"
                # Handle git config variables
                string lower (string replace -a '_' '.' (string replace -a GIT_ '' $env_var)) | read git_config_key
                git config --global $git_config_key $$env_var
        end
    end
    cat ~/.gitconfig
end