aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/wsl.install
blob: 6e1b1c367516a1e1cbd1d0c2e75b4255cf543004 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
DOTFILES="${DOTFILES:-${BASEDIR:-${HOME}/dotfiles}}"
WINHOME="$(wslpath "$(powershell.exe -NoProfile -c \$HOME)")"
force=1

function mkln() {
    dir="$(dirname $2)"
    file="$(basename $2)"
    source=$(wslpath -w $DOTFILES/$1)
    target=$(wslpath -w $dir)\\$file
    cmd="cd ~; cmd /c mklink $target $source"

    if ls -la $dir/ 2>/dev/null | grep -q $file; then
        if [ $force = 1 ]; then
            cmd="cd ~; rm $target; cmd /c mklink $target $source"
        else
            echo "$file already exists. Use -f to overwrite."
            return
        fi
    fi
    powershell.exe -c "$cmd" &>/dev/null
    echo "linked $2 --> $1"
}

function 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"
}

ln -sf $WINHOME ~/win
ln -sf $WINHOME/Sync ~/win/sync
ln -sf $WINHOME/siue ~/win/siue

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
mkln wt.json ~/win/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json
mkln winget.json ~/win/AppData/Local/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/LocalState/settings.json

if gpg.exe --keyserver hkps://keys.openpgp.org --recv-key 0xC8F6E06F5C8E2634 &>/dev/null; then
    echo "gpg key imported"
else
    echo "Failed to import gpg key"
fi

if gpg.exe --import-ownertrust $DOTFILES/gnupg/trustfile.txt; then
    echo "gpg trust imported"
else
    echo "Failed to import gpg trust"
fi