rework symlinking and locations of several files

master
Alan Faubert 1 year ago
parent 0ab51ff834
commit dbbbbb3060
  1. 2
      bash/.gitignore
  2. 9
      bash/README.md
  3. 2
      bash/config/.bashrc
  4. 2
      bash/config/.profile
  5. 71
      config.sh
  6. 2
      firefox/.gitignore
  7. 8
      firefox/README.md
  8. 2
      gcloud/README.md
  9. 0
      gcloud/gcloud/.gitignore
  10. 0
      ssh/.ssh/.gitignore
  11. 2
      ssh/README.md
  12. 2
      vscode/README.md
  13. 0
      vscode/config/keybindings.json
  14. 0
      vscode/config/settings.json
  15. 0
      vscode/server-config/server-env-setup

2
bash/.gitignore vendored

@ -1,2 +0,0 @@
/config/.bashrc.*
/config/.profile.*

@ -1,15 +1,10 @@
# Bash
## `.gitignore`'d
- `config/.bashrc.*` - additional commands to run when sourcing `~/.bashrc`
- `config/.profile.*` - additional commands to run when sourcing `~/.profile`
# Config
[`config/.bashrc`](config/.bashrc) contains code that's symlinked to from `~/.bashrc`. [`config/.profile`](config/.profile) contains code that's symlinked to from `~/.profile`.
[`config/*`](config) contains code that's symlinked to from `~`.
If you create additional `config/.bashrc.*` or `config/.profile.*` files, they will also be run when sourcing `~/.bashrc` or `~/.profile`, respectively. This can be used for additional commands that shouldn't be checked into this repo.
If you create additional `~/.bashrc.d/*` or `~/.profile.d/*` files, they will also be run when sourcing `~/.bashrc` or `~/.profile`, respectively. This can be used for additional commands that shouldn't be checked into this repo.
## Scripts

@ -17,7 +17,7 @@ if [ $? = 2 ]; then
fi
# Run additional code if present
for file in "$(readlink --canonicalize ~/.bashrc)".*; do
for file in ~/.bashrc.d/*; do
if [ -f "$file" ]; then
source "$file"
fi

@ -9,7 +9,7 @@ for dir in ~/bin/* ~/.local/bin/*; do
done
# Run additional code if present
for file in "$(readlink --canonicalize ~/.profile)".*; do
for file in ~/.profile.d/*; do
if [ -f "$file" ]; then
. "$file"
fi

@ -1,4 +1,13 @@
#!/bin/bash
link_to() {
d="$1" && mkdir --parents "$d" && shift || return 1
for f in "$@"; do
[ -e "$f" ] || continue
base="$(basename "$f")" || return 1
[[ "$base" = . || "$base" = .. ]] && continue
rm --force --recursive "$d/$base" && ln --relative --symbolic "$f" "$d/$base" && echo "$d/$base -> $f" || return 1
done
}
cd "$(dirname "$(readlink --canonicalize "$0")")"
root_win="$([[ "$(uname --kernel-release)" =~ microsoft ]] && wslpath -w .)"
while :; do
@ -7,7 +16,7 @@ while :; do
bash- 'Bash' bash ' Create ~/* symlinks to config' bash-scripts ' Set up util scripts' \
ssh- 'SSH' ssh ' Create config symlinks (Linux+Windows)' \
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)' vscode-server-env-setup ' Create ~/.vscode-server/server-env-setup symlink' \
vscode- 'VS Code' vscode-ext ' Install extensions (Linux/Windows)' vscode ' Create config symlinks (Linux+Windows)' vscode-server-env-setup ' Create ~/.vscode-server/server-env-setup symlink' \
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' \
@ -22,25 +31,22 @@ while :; do
ln --relative --symbolic "$(wslpath "$(wslvar USERPROFILE)")" ~/win
;;
wsl-wsltty)
{ cmd.exe /c rmdir /s /q "%APPDATA%\wsltty" 2\> nul; cmd.exe /c mklink /d "%APPDATA%\wsltty" "$root_win\wsl\wsltty"; }
link_to "$(wslpath "$(wslvar APPDATA)")" wsl/wsltty
;;
bash)
for file in bash/config/.?*; do
[[ "$(basename "$file")" =~ \..*\. ]] || ln --force --relative --symbolic "$file" ~/"$(basename "$file")"
done
link_to ~ bash/config/{.*,*}
;;
bash-scripts)
bash/scripts/2path.sh bash/scripts
;;
ssh)
rm --force --recursive ~/.ssh &&
ln --relative --symbolic ssh/config ~/.ssh &&
link_to ~ ssh/.ssh &&
chmod 600 ~/.ssh/* &&
[ -z "$root_win" ] || { cmd.exe /c rmdir /s /q "%USERPROFILE%\.ssh" 2\> nul; cmd.exe /c mklink /d "%USERPROFILE%\.ssh" "$root_win\ssh\config"; }
{ [ -z "$root_win" ] || link_to "$(wslpath "$(wslvar USERPROFILE)")" ssh/.ssh; }
;;
git)
ln --force --relative --symbolic git/.gitconfig ~/.gitconfig &&
[ -z "$root_win" ] || { cmd.exe /c del "%USERPROFILE%\.gitconfig" 2\> nul; cmd.exe /c mklink "%USERPROFILE%\.gitconfig" "$root_win\git\.gitconfig"; }
link_to ~ git/.gitconfig &&
{ [ -z "$root_win" ] || link_to "$(wslpath "$(wslvar USERPROFILE)")" git/.gitconfig; }
;;
git-delta)
mkdir --parents ~/.bin &&
@ -59,27 +65,17 @@ while :; do
if [ "$root_win" ]; then cmd.exe /c $ext; else $ext; fi
;;
vscode)
if [ "$root_win" ]; then
{ cmd.exe /c del "%APPDATA%\Code\User\keybindings.json" 2\> nul; cmd.exe /c mklink "%APPDATA%\Code\User\keybindings.json" "$root_win\vscode\keybindings.json"; } &&
{ cmd.exe /c del "%APPDATA%\Code\User\settings.json" 2\> nul; cmd.exe /c mklink "%APPDATA%\Code\User\settings.json" "$root_win\vscode\settings.json"; }
else
mkdir --parents ~/.config/Code/User &&
ln --force --relative --symbolic vscode/keybindings.json ~/.config/Code/User/keybindings.json &&
ln --force --relative --symbolic vscode/settings.json ~/.config/Code/User/settings.json
fi
link_to ~/.config/Code/User vscode/config/* &&
{ [ -z "$root_win" ] || link_to "$(wslpath "$(wslvar APPDATA)")"/Code/User vscode/config/*; }
;;
vscode-server-env-setup)
mkdir --parents ~/.vscode-server &&
ln --force --relative --symbolic vscode/server-env-setup ~/.vscode-server/server-env-setup
link_to ~/.vscode-server vscode/server-config/*
;;
nodejs-npmrc)
ln --force --relative --symbolic nodejs/.npmrc ~/.npmrc
link_to ~ nodejs/.npmrc
;;
nodejs-config)
mkdir --parents ~/dev &&
for file in nodejs/config/{.*,*}; do
[[ "$file" == */. ]] || [[ "$file" == */.. ]] || ln --force --relative --symbolic "$file" ~/dev/"$(basename "$file")"
done
link_to ~/dev nodejs/config/{.*,*}
;;
nodejs-scripts)
bash/scripts/2path.sh nodejs/scripts
@ -89,39 +85,36 @@ while :; do
bash/scripts/2path.sh ~/.bin/gcloud/bin/gcloud
;;
gcloud-config)
mkdir --parents ~/.config &&
rm --force --recursive ~/.config/gcloud &&
ln --relative --symbolic gcloud/config ~/.config/gcloud
link_to ~/.config gcloud/gcloud
;;
tmux)
ln --force --relative --symbolic tmux/.tmux.conf ~/.tmux.conf
link_to ~ tmux/.tmux.conf
;;
firefox-rebuild-win)
ls firefox/*+* | cut --characters=9- | while read config; do
truncate --size=0 firefox/"$config"
for dir in firefox/*; do
[ -d "$dir" ] || continue
config="$(basename "$dir")"
truncate --size=0 firefox/"$config"/user.js
IFS='+' read -a pieces <<< "$config"
for piece in "${pieces[@]}"; do
[ -f firefox/"$piece".js ] && cat firefox/"$piece".js >> firefox/"$config"
[ -f firefox/"$piece".pac ] && echo 'user_pref("network.proxy.autoconfig_url", "'file:///"${root_win//\\//}"/firefox/"$piece".pac$'");\nuser_pref("network.proxy.type", 2);' >> firefox/"$config"
[ -f firefox/"$piece".js ] && cat firefox/"$piece".js >> firefox/"$config"/user.js
[ -f firefox/"$piece".pac ] && echo 'user_pref("network.proxy.autoconfig_url", "'file:///"${root_win//\\//}"/firefox/"$piece".pac$'");\nuser_pref("network.proxy.type", 2);' >> firefox/"$config"/user.js
done
done
true
;;
firefox-link-win)
profile_dir="$(wslpath "$(wslvar APPDATA)")"/Mozilla/Firefox/Profiles
mapfile -t profiles < <(ls "$profile_dir")
profiles_args=()
for ((i=0; i < ${#profiles[@]}; i++)); do profiles_args[2*i]="${profiles[$i]}"; profiles_args[2*i+1]="${profiles[$i]}"; done
mapfile -t configs < <(ls firefox/*+* | cut --characters=9-)
for dir in "$profile_dir"/*; do [ -d "$dir" ] || continue; base="$(basename "$dir")"; profiles_args+=("$base"); profiles_args+=("$base"); done
configs_args=()
for ((i=0; i < ${#configs[@]}; i++)); do configs_args[2*i]="${configs[$i]}"; configs_args[2*i+1]="${configs[$i]}"; done
for dir in firefox/*; do [ -d "$dir" ] || continue; base="$(basename "$dir")"; configs_args+=("$base"); configs_args+=("$base"); done
while :; do
profile="$(whiptail --title 'Select profile' --menu '' 22 60 15 "${profiles_args[@]}" --notags --default-item "$profile" 3>&2 2>&1 1>&3-)"
[ "$profile" = '' ] && break
config="$(whiptail --title "Link $profile to config" --menu '' 22 60 15 "${configs_args[@]}" --notags --default-item "$config" 3>&2 2>&1 1>&3-)"
[ "$config" = '' ] && break
rm --force "$profile_dir"/"$profile"/user.js
cmd.exe /c mklink %APPDATA%\\Mozilla\\Firefox\\Profiles\\"$profile"\\user.js "$root_win"\\firefox\\"$config"
link_to "$profile_dir/$profile" firefox/"$config"/user.js
done
;;
'')

@ -1,2 +1,2 @@
/*+*
/*/
/*.pac

@ -2,18 +2,18 @@
## `.gitignore`'d
- `*+*` - files whose names are `+`-separated filenames of base names of other files in this directory - these will be constructed by concatenation of the base files, and will be symlinked to from various Firefox profiles' `user.js` files
- `*/` - folders whose names are `+`-separated concatenations of base names of files in this directory - these will be given `user.js` files constructed by concatenation of the base files, and will be symlinked to from various Firefox profiles' `user.js` files
- `*.pac` - proxy auto-config files - these too can be referred to in the above `configs/*` files
## `user.js` handling (Windows-specific)
Create `*.pac` files containing proxy auto-config files.
Create empty `*+*` files whose names are assembled by concatenating the base names of templates in this directory (without the `.js` or `.pac` extension) separated by `+`s.
Create empty directories whose names are assembled by concatenating the base names of templates in this directory (without the `.js` or `.pac` extension) separated by `+`s.
There is a menu option in `config.sh` to generate (or regenerate) the `*+*` files from their constituent templates, including adding the appropriate configuration to point to a particular `*.pac` file.
There is a menu option in `config.sh` to generate (or regenerate) `user.js` files in these directories from their constituent templates, including adding the appropriate configuration to point to a particular `*.pac` file.
There is also a menu option in `config.sh` for creating symlinks from various Firefox profiles' `user.js` files to the assembled `*+*` files.
There is also a menu option in `config.sh` for creating symlinks from various Firefox profiles' `user.js` files to the assembled files.
## Additional manual setup

@ -2,4 +2,4 @@
## `.gitignore`'d
- `config/*` - Google Cloud SDK configuration files
- `gcloud/*` - Google Cloud SDK configuration files

@ -2,4 +2,4 @@
## `.gitignore`'d
- `config/*` - SSH keys, config, etc.
- `.ssh/*` - SSH keys, config, etc.

@ -2,7 +2,7 @@
## Settings and keybindings
[`settings.json`](settings.json) and [`keybindings.json`](keybindings.json) are VS Code's configuration files.
[`config/*`](config) contains VS Code's configuration files. [`server-config/*`](server-config) contains `~/.vscode-server` configuration files.
### Font

Loading…
Cancel
Save