aboutsummaryrefslogtreecommitdiff
path: root/.config/fish/functions/load_dots.fish
blob: 6a01343e715eaa3eeb11ba0e072b12b9306ef5b6 (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
function load_dots
    set -l options git
    count $argv | read arg_count
    if test $arg_count -eq 0
        printf "options: %s\n" $options[1]
    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
    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
end