138 lines
5.9 KiB
Bash
Executable File
138 lines
5.9 KiB
Bash
Executable File
#!/bin/bash
|
|
get_var_path() { wslpath "$(cmd.exe /c echo %$1% | tr --delete \\r)"; }
|
|
whiptail_menu() { whiptail ${1:+--title "$1"} --menu '' $(tput lines) $(tput cols) $(($(tput lines) - 7)) "${@:3}" --notags --default-item "$2" 3>&2 2>&1 1>&3-; }
|
|
cd "$(dirname "$(readlink --canonicalize "$0")")"
|
|
PATH="$PWD/bash/scripts:$PATH"
|
|
is_wsl="$([[ "$(uname --kernel-release)" =~ [Mm]icrosoft ]] && echo yes)"
|
|
while :; do
|
|
action="$(whiptail_menu '' "$action" \
|
|
wsl- 'WSL' wsl ' Create global config symlinks' wsl-scripts ' Set up WSL helper scripts' wsl-win ' Create symlinks to Windows profile folders' \
|
|
bash- 'Bash' bash ' Create ~/* symlinks to config' bash-scripts ' Set up util scripts' bash-optional-profile ' Create optional ~/.profile.d/* symlinks' bash-optional-bashrc ' Create optional ~/.bashrc.d/* symlinks' \
|
|
git- 'Git' git ' Create config symlinks (Linux+Windows)' git-delta ' Install Delta' git-filter-repo ' Install git-filter-repo' git-scripts ' Set up various scripts' \
|
|
vscode- 'VS Code' vscode-ext ' Install extensions (Linux/Windows)' vscode ' Create config symlinks (Linux+Windows)' \
|
|
nodejs- 'Node.js' nodejs-npmrc ' Create ~/.npmrc symlink' nodejs-config ' Create ~/dev/* symlinks to config' nodejs-scripts ' Set up various scripts' \
|
|
gcloud- 'Google Cloud SDK' gcloud ' Install' gcloud-config ' Create config symlinks' \
|
|
tmux- 'tmux' tmux ' Create config symlinks' \
|
|
firefox- 'Firefox' firefox-rebuild-win ' Rebuild configs from templates (Windows)' firefox-link-win ' Create user.js symlinks (Windows)' \
|
|
)"
|
|
case "$action" in
|
|
wsl)
|
|
2link.sh "$(get_var_path USERPROFILE)" wsl/.wslconfig
|
|
;;
|
|
wsl-scripts)
|
|
2path.sh wsl/scripts
|
|
;;
|
|
wsl-win)
|
|
profile="$(get_var_path USERPROFILE)" &&
|
|
for dir in AppData Desktop Documents Downloads Music Pictures Videos; do
|
|
if [ -d "$profile"/OneDrive/"$dir" ]; then
|
|
2link.sh ~ "$profile"/OneDrive/"$dir"
|
|
elif [ -d "$profile"/"$dir" ]; then
|
|
2link.sh ~ "$profile"/"$dir"
|
|
fi
|
|
done
|
|
;;
|
|
bash)
|
|
2link.sh ~ bash/config/{.*,*}
|
|
;;
|
|
bash-scripts)
|
|
2path.sh bash/scripts
|
|
;;
|
|
bash-optional-profile)
|
|
args=(); for f in bash/optional/*.profile; do base="$(basename "$f")"; args+=("$base" "$base"); done
|
|
while :; do f="$(whiptail_menu 'Select *.profile' "$f" "${args[@]}")"; [ "$f" = '' ] && break; 2link.sh ~/.profile.d bash/optional/"$f"; done
|
|
;;
|
|
bash-optional-bashrc)
|
|
args=(); for f in bash/optional/*.bashrc; do base="$(basename "$f")"; args+=("$base" "$base"); done
|
|
while :; do f="$(whiptail_menu 'Select *.bashrc' "$f" "${args[@]}")"; [ "$f" = '' ] && break; 2link.sh ~/.bashrc.d bash/optional/"$f"; done
|
|
;;
|
|
git)
|
|
2link.sh ~ git/.gitconfig &&
|
|
{ [ -z "$is_wsl" ] || 2link.sh "$(get_var_path USERPROFILE)" git/.gitconfig; }
|
|
;;
|
|
git-delta)
|
|
mkdir --parents ~/.bin/delta &&
|
|
wget https://github.com"$(curl --silent https://github.com/dandavison/delta/releases | grep --max-count=1 --only-matching '[^\"]*x86_64-unknown-linux-musl[^\"]*')" --output-document=- | tar --extract --directory ~/.bin/delta --gzip --strip-components=1
|
|
;;
|
|
git-filter-repo)
|
|
[ -d ~/.bin/git-filter-repo ] && git -C ~/.bin/git-filter-repo pull || { mkdir --parents ~/.bin && git clone https://github.com/newren/git-filter-repo ~/.bin/git-filter-repo; } &&
|
|
2path.sh ~/.bin/git-filter-repo/git-filter-repo
|
|
;;
|
|
git-scripts)
|
|
2path.sh git/scripts
|
|
;;
|
|
vscode-ext)
|
|
ext="code --install-extension dbaeumer.vscode-eslint --install-extension eamodio.gitlens --install-extension esbenp.prettier-vscode --install-extension ms-vscode-remote.vscode-remote-extensionpack --install-extension streetsidesoftware.code-spell-checker --install-extension svelte.svelte-vscode" &&
|
|
if [ "$is_wsl" ]; then cmd.exe /c $ext; else $ext; fi
|
|
;;
|
|
vscode)
|
|
2link.sh ~/.config/Code/User vscode/config/* &&
|
|
{ [ -z "$is_wsl" ] || {
|
|
2link.sh "$(get_var_path APPDATA)"/Code/User vscode/config/* &&
|
|
2link.sh ~/.vscode-server vscode/wsl_server_config/*
|
|
}; }
|
|
;;
|
|
nodejs-npmrc)
|
|
2link.sh ~ nodejs/.npmrc
|
|
;;
|
|
nodejs-config)
|
|
2link.sh ~/dev nodejs/config/{.*,*}
|
|
;;
|
|
nodejs-scripts)
|
|
2path.sh nodejs/scripts
|
|
;;
|
|
gcloud)
|
|
[ -d ~/.bin/gcloud ] || { mkdir --parents ~/.bin/gcloud && wget "$(curl --silent https://cloud.google.com/sdk/docs/downloads-versioned-archives | grep --only-matching 'https[^\"]*linux-x86_64.tar.gz')" --output-document=- | tar --extract --directory ~/.bin/gcloud --gzip --strip-components=1; } &&
|
|
2path.sh ~/.bin/gcloud/bin/gcloud
|
|
;;
|
|
gcloud-config)
|
|
2link.sh ~/.config gcloud/gcloud
|
|
;;
|
|
tmux)
|
|
2link.sh ~ tmux/.tmux.conf
|
|
;;
|
|
firefox-rebuild-win)
|
|
for dir in firefox/*; do
|
|
[ -d "$dir" ] && {
|
|
echo '//'
|
|
echo "// Generated at $(date)"
|
|
echo '//'
|
|
IFS='+' read -a pieces <<< "$(basename "$dir")"
|
|
for piece in "${pieces[@]}"; do
|
|
if [ -f firefox/"$piece".js ]; then
|
|
echo "// --- $piece.js ---"
|
|
cat firefox/"$piece".js
|
|
fi
|
|
if [ -f firefox/"$piece".pac ]; then
|
|
echo "// --- $piece.pac ---"
|
|
echo "user_pref(\"network.proxy.autoconfig_url\", \"file:///$(wslpath -m .)/firefox/$piece.pac\");"
|
|
echo 'user_pref("network.proxy.type", 2);'
|
|
fi
|
|
done
|
|
} > "$dir"/user.js
|
|
done
|
|
true
|
|
;;
|
|
firefox-link-win)
|
|
profile_dir="$(get_var_path APPDATA)"/Mozilla/Firefox/Profiles
|
|
profiles_args=()
|
|
for dir in "$profile_dir"/*; do [ -d "$dir" ] || continue; base="$(basename "$dir")"; profiles_args+=("$base" "$base"); done
|
|
configs_args=()
|
|
for dir in firefox/*; do [ -d "$dir" ] || continue; base="$(basename "$dir")"; configs_args+=("$base" "$base"); done
|
|
while :; do
|
|
profile="$(whiptail_menu 'Select profile' "$profile" "${profiles_args[@]}")"
|
|
[ "$profile" = '' ] && break
|
|
config="$(whiptail_menu "Link $profile to config" "$config" "${configs_args[@]}")"
|
|
[ "$config" = '' ] && break
|
|
2link.sh "$profile_dir/$profile" firefox/"$config"/user.js
|
|
done
|
|
;;
|
|
'')
|
|
break
|
|
;;
|
|
*)
|
|
false
|
|
;;
|
|
esac && whiptail --msgbox Done 7 10
|
|
done
|