summaryrefslogtreecommitdiffstatshomepage
path: root/wsl.install
blob: 4680de303e59f4121c860b22bdfb8c4fcfa24d42 (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
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash

DOTFILES="$(dirname "$(readlink -fm "$0")")"
force=1

mkln() {
    dirname="$(dirname $2)"
    filename="$(basename $2)"

    if ls -la $dirname/ 2>/dev/null | grep -q $filename ; then
        if [ $force = 1 ]; then
            rm $2
        else
            echo "$filename already exists. Use -f to overwrite."
            return
        fi
    fi
    source=$(wslpath -w $DOTFILES/$1)
    target=$(wslpath -w $dirname)\\$filename
    powershell.exe -c "cd ~; cmd /c mklink $target $source"
}

show-warning() {
    gpgpath=$(wslpath -w "$(command -v gpg.exe)")
    gitgpg=$(git.exe config --system --get gpg.program)
    if [ "$gitgpg" = "$gpgpath" ]; then
        return
    fi
    printf "\n"
    printf "In order to use gpg with git for windows \n"
    printf "(and still share gitconfigs), you need to run\n"
    printf "the following command from an admin terminal:\n"
    printf "\n"
    printf "git.exe config --system gpg.program '%s' \n" "$(wslpath -w "$(command -v gpg.exe)")"
    printf "\n"
}

mkln ssh/win.config ~/win/.ssh/config
mkln gitconfig ~/win/.gitconfig
mkln gnupg/gpg.conf ~/win/AppData/Roaming/gnupg/gpg.conf
mkln gnupg/gpg-agent.conf ~/win/AppData/Roaming/gnupg/gpg-agent.conf
mkln gnupg/scdaemon.conf ~/win/AppData/Roaming/gnupg/scdaemon.conf