#!/usr/bin/env bash DOTFILES="${DOTFILES:-${BASEDIR:-${HOME}/dotfiles}}" cd $DOTFILES # BUG Has issues with a return character? # WINHOME="$(wslpath "$(powershell.exe -NoProfile -c \$HOME)")" WINHOME="$(wslpath c:\\Users\\${USER})" RESET='\033[0m' RED='\033[91m' GREEN='\033[92m' YELLOW='\033[93m' BLUE='\033[94m' MAGENTA='\033[95m' mkln="${DOTFILES}/scripts/mkln.sh -f" function show-warning() { gpgpath=$(wslpath -w "$(command -v gpg.exe)") gitgpg=$(git.exe config --system --get gpg.program) if [ "$gitgpg" = "$gpgpath" ]; then return fi echo echo -e "${BLUE}In order to use gpg with git for windows" echo -e "${BLUE}(and still share gitconfigs), you need to run" echo -e "${BLUE}the following command from an admin terminal:" echo echo "git.exe config --system gpg.program '$(wslpath -w "$(command -v gpg.exe)")'" echo } echo -e "${BLUE}Setting up WSL" # link WINHOME ln -sfn $WINHOME ~/win # ssh-config sed -r 's|(RemoteForward\s+.+\s+)\/home\/tobyv\/\.gnupg\/S\.gpg-agent\.extra|\1127.0.0.1:4444|' \ ${DOTFILES}/ssh/config | sed '/Control/d' >${DOTFILES}/ssh/win.config # Create windows symlinks to dotfiles $mkln $@ "ssh/win.config" "${WINHOME}/.ssh/config" $mkln $@ "gitconfig" "${WINHOME}/.gitconfig" $mkln $@ "gnupg/gpg.conf" "${WINHOME}/AppData/Roaming/gnupg/gpg.conf" $mkln $@ "gnupg/gpg-agent.conf" "${WINHOME}/AppData/Roaming/gnupg/gpg-agent.conf" $mkln $@ "gnupg/scdaemon.conf" "${WINHOME}/AppData/Roaming/gnupg/scdaemon.conf" $mkln $@ "wt.json" "${WINHOME}/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json" $mkln $@ "winget.json" "${WINHOME}/AppData/Local/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/LocalState/settings.json" # install hotkeys.exe install_dir="${WINHOME}/AppData/Local/Programs/hotkeys" mkdir -p "${install_dir}" curl -sL "https://github.com/tobyvin/hotkeys/releases/latest/download/hotkeys.exe" >"${install_dir}/hotkeys.exe" # https://github.com/wslutilities/wslu if ! command -v wslview &>/dev/null; then echo "wslu is not installed." echo "wslu (wslview) is needed to open browser windows from linux commands." echo "install instructions: https://github.com/wslutilities/wslu#installation" fi # Import gpg key if gpg.exe --recv-key 0xC8F6E06F5C8E2634 &>/dev/null; then echo -e "${BLUE}gpg key imported" else echo -e "${MAGENTA}Failed to import gpg key" fi # Import gpg trust if gpg.exe --import-ownertrust $DOTFILES/gnupg/trustfile.txt; then echo -e "${BLUE}gpg trust imported" else echo -e "${MAGENTA}Failed to import gpg trust" fi echo -e "${GREEN}WSL has been set up"