1
Fork 0

reorganize

This commit is contained in:
Alan Faubert 2021-01-15 10:31:42 -05:00
parent 894a1cb46d
commit e163ef937e
22 changed files with 174 additions and 117 deletions

6
.gitignore vendored
View File

@ -1,6 +0,0 @@
/firefox/configs
/firefox/*.proxy
/gcloud
/git/github_token
/nodejs/.npmrc
/ssh

View File

@ -1,90 +1,17 @@
# config
My config files for various things. Use `config.sh` to automate the setup of several of them.
My config files for various things. See the individual readmes below.
Things that are not checked in but which should live in this directory:
- [Windows](win)
- [WSL](wsl)
- [Bash](bash)
- [SSH](ssh)
- [Git](git)
- [VS Code](vscode)
- [Node.js](nodejs)
- [Google Cloud SDK](gcloud)
- [tmux](tmux)
- [Firefox](firefox)
- [KeePass](keepass)
- `firefox/configs/` - files whose names are `+`-separated filenames from `firefox/` - these will be constructed by concatenation from the base files, and will be symlinked to from various profiles' `user.js` files
- `firefox/*.proxy` - proxy auto-config files - these too can be referred to in the above `firefox/configs/` files, without the `.proxy` extension
- `gcloud/` - Google Cloud SDK configuration files
- `git/github_token` - GitHub Personal Access Token with read access to repos
- `nodejs/.npmrc` - npm credentials, config, etc.
- `ssh/` - SSH keys, config, etc.
## Bash scripts
- `2path.sh` - create a symlink to a file or directory from `~/bin`
- `syncfiles.sh` - given paths to two or more files, prompt to copy the newest one over each of the older ones
## WSL setup
Use `wsl/install.cmd` to set up a new WSL installation. Run without arguments for details.
## WSL scripts
- `wsl-apt` - run `apt-get update`/`upgrade`/`install`/`remove`/`autoremove`/`autoclean`
- any package names given as arguments are treated as packages to `install`, except any prefixed with a `-` are treated as packages to `remove`
- `wsl-expose-ports` - expose one or more ports within WSL to the outside world
- this sets up a port proxy and a Windows firewall rule for each exposed port, and removes previous port proxies and firewall rules
- multiple ports can be specified, each with an optional external port: `1234` exposes port 1234 as 1234, `1234:5678` exposes port 5678 as 1234
- call without arguments to remove port proxies and firewall rules without creating new ones
- `wsl-fix-clock` - sync the WSL clock with the Windows clock
- `wsl-fix-interop` - fix `WSL_INTEROP` variable when it becomes incorrectly set
- `wsl-services` - start useful services not automatically started by WSL
- starts `procps` for `sysctl` configuration
## Firefox
For each profile:
- Use the script commands to create a symlink for `user.js`
- Change the [default search engine](about:preferences#search) to DuckDuckGo
- Current approximate complement of add-ons (varies by profile):
- [Buster: Captcha Solver for Humans](https://addons.mozilla.org/addon/buster-captcha-solver/)
- [Feedbro](https://addons.mozilla.org/addon/feedbroreader/)
- [Greasemonkey](https://addons.mozilla.org/addon/greasemonkey/)
- [Kee - Password Manager](https://addons.mozilla.org/addon/keefox/)
- [NoScript Security Suite](https://addons.mozilla.org/addon/noscript/)
- [RSSPreview](https://addons.mozilla.org/addon/rsspreview/)
- [uBlock Origin](https://addons.mozilla.org/addon/ublock-origin/)
## Git scripts
- `git clean-branches` - delete local branches which track deleted remote branches
- `git clean-config` - unset various local config values, so global config will be used
- `git clean-dates` - set commit dates of all commits in the given range to their authoring dates
- `git clean-fork` - assuming `origin` and `fork` remotes, resets default branch on `fork` to first commit on `origin`, deletes all other branches on `fork` that are present on `origin`, and deletes all tags on `fork`
- `git clean-modes` - reset all file modes to those in the repository
- `git clean-mtime` - set a file's mtime to its most recent commit's author date
- `git clean-pr` - delete all `pr/` branches created by `git cpr`
- `get clean-user` - set author and committer of all commits in the given range to the currently configured identity
- `git cpr` - checkout a PR from GitHub by id, and set up the local branch to track the appropriate branch on the appropriate fork
- `git download-bundle` - download a bundle file from a remote repository
- `git index-list-skip` - list all files that have had `--skip-worktree` set on them
- `git index-skip` - set `--skip-worktree` on a given file
- `git index-unskip` - set `--no-skip-worktree` on a given file
- `git npm-add` - stage precisely the files that would be included in an npm package
- `git track` - set current branch to track given remote and branch, defaulting to same branch name
- `git turbo-gc` - turbo garbage collect
## Git Credential Manager Core WSL/Windows interop
Copy `git/wsl/git-credential-manager` into the root of the Git for Windows installation, and symlink to it from the WSL `PATH`.
## Node.js/npm scripts
- `npma.sh` - find the given binaries searching upwards through `node_modules` and output aliases for them, suitable for `>> ~/.bash_aliases`
- `npmg.sh` - create a commit for a new version (if there are staged changed), and create and tag an otherwise dangling commit from HEAD that contains all of the files `npm publish` would
- `npml.sh` - find the `node_modules` where the given dependencies are used, search up further for directories defining them, and create symlinks
## tmux keybindings
The included `.tmux.conf` makes the following changes/additions to the default tmux keybindings:
- The prefix key is now `ctrl-a` (and `ctrl-a ctrl-a` is used to send `ctrl-a` to the console)
- Switching windows is done with `ctrl-alt-left/right` (no prefix key)
- Switching panes is done with `alt-left/right/up/down` (no prefix key)
- Splitting panes is done with `ctrl-a |` (horizontal) and `ctrl-a -` (vertical)
- Reloading `~/.tmux.conf` is done with `ctrl-a shift-r`
Mouse control is also enabled, and the terminal mode is set to `screen-256color`.
Use `config.sh` to automate the setup of a number of things.

View File

@ -1,4 +1,9 @@
# Bash Config
# Bash
## Scripts
- [`2path.sh`](scripts/2path.sh) - create a symlink to a file or directory from `~/bin`
- [`syncfiles.sh`](scripts/syncfiles.sh) - given paths to two or more files, prompt to copy the newest one over each of the older ones
## Adding color to root user shells

View File

@ -4,36 +4,37 @@ root_win="$(wslpath -w .)"
root_win_slash="$(wslpath -m .)"
while :; do
action="$(whiptail --menu '' 22 60 15 \
wsl- 'WSL' wsl-win ' Create ~/win symlink to %USERPROFILE%' wsl-hosts ' Create /etc/hosts symlink to system' wsl-resolvconf ' Create /etc/resolv.conf' wsl-elevate ' Set up wsl-elevate' wsl-scripts ' Set up WSL helper scripts' \
wsl- 'WSL' wsl-resolvconf ' Create /etc/resolv.conf' wsl-hosts ' Create /etc/hosts symlink to system' wsl-elevate ' Set up wsl-elevate' wsl-scripts ' Set up WSL helper scripts' wsl-win ' Create ~/win symlink to %USERPROFILE%' wsl-wsltty ' Create WSLtty config symlinks (Windows)' \
bash- 'Bash' bash-profile ' Create ~/.profile symlink' bash-scripts ' Set up util scripts' bash-completion ' Create ~/.bash_completion.d symlink' \
ssh- 'SSH' ssh ' Create config symlinks' ssh-win ' Create config symlinks (Windows)' \
git- 'Git' git ' Create config symlinks' git-win ' Create config symlinks (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' vscode-linux ' Create config symlinks (Linux) ' vscode-win ' Create config symlinks (Windows)' vscode-local-win ' Create local extension symlink (Windows)' \
wsltty- 'WSLtty' wsltty ' Create config symlinks (Windows)' \
nodejs- 'Node.js' nodejs-volta ' Install Volta' 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)' \
win- 'Windows' win-developer-mode ' Enable developer mode' win-scancode-map ' Swap caps lock and context key' \
--notags --default-item "$action" 3>&2 2>&1 1>&3-)"
case "$action" in
wsl-win)
rm -rf ~/win &&
ln -s "$(wslpath "$(wslvar USERPROFILE)")" ~/win
;;
wsl-hosts)
wsl.exe -d $WSL_DISTRO_NAME -u $(id -un 0) -- ln -fs "$(wslpath "$(wslvar WINDIR)")"/System32/drivers/etc/hosts /etc/hosts
;;
wsl-resolvconf)
wsl.exe -d $WSL_DISTRO_NAME -u $(id -un 0) -- rm /etc/resolv.conf
wsl.exe -d $WSL_DISTRO_NAME -u $(id -un 0) -- echo $'nameserver 1.1.1.1\nnameserver 1.0.0.1' \> /etc/resolv.conf
;;
wsl-hosts)
wsl.exe -d $WSL_DISTRO_NAME -u $(id -un 0) -- ln -frs "$(wslpath "$(wslvar WINDIR)")"/System32/drivers/etc/hosts /etc/hosts
;;
wsl-elevate)
wsl.exe -d $WSL_DISTRO_NAME -u $(id -un 0) -- ln -fs $PWD/wsl/wsl-elevate /usr/local/bin/wsl-elevate
wsl.exe -d $WSL_DISTRO_NAME -u $(id -un 0) -- ln -frs wsl/wsl-elevate /usr/local/bin/wsl-elevate
;;
wsl-scripts)
bash/scripts/2path.sh wsl/scripts
;;
wsl-win)
rm -rf ~/win &&
ln -rs "$(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")
;;
bash-profile)
ln -frs bash/.profile ~/.profile
;;
@ -46,11 +47,11 @@ while :; do
;;
ssh)
rm -rf ~/.ssh &&
ln -rs ssh ~/.ssh &&
ln -rs ssh/config ~/.ssh &&
chmod 600 ~/.ssh/*
;;
ssh-win)
(cmd.exe /c rmdir /s /q "%USERPROFILE%\.ssh" 2\> nul; cmd.exe /c mklink /d "%USERPROFILE%\.ssh" "$root_win\ssh")
(cmd.exe /c rmdir /s /q "%USERPROFILE%\.ssh" 2\> nul; cmd.exe /c mklink /d "%USERPROFILE%\.ssh" "$root_win\ssh\config")
;;
git)
ln -frs git/.gitconfig ~/.gitconfig
@ -87,9 +88,6 @@ while :; do
vscode-local-win)
(cmd.exe /c rmdir /s /q "%USERPROFILE%\.vscode\extensions\local" 2\> nul; cmd.exe /c mklink /d "%USERPROFILE%\.vscode\extensions\local" "$root_win\vscode\local-extension")
;;
wsltty)
(cmd.exe /c rmdir /s /q "%APPDATA%\wsltty" 2\> nul; cmd.exe /c mklink /d "%APPDATA%\wsltty" "$root_win\wsl\wsltty")
;;
nodejs-volta)
curl https://get.volta.sh | bash -s -- --skip-setup &&
bash/scripts/2path.sh ~/.volta/bin
@ -113,7 +111,7 @@ while :; do
gcloud-config)
mkdir -p ~/.config &&
rm -rf ~/.config/gcloud &&
ln -rs gcloud ~/.config/gcloud
ln -rs gcloud/config ~/.config/gcloud
;;
tmux)
ln -frs tmux/.tmux.conf ~/.tmux.conf
@ -146,12 +144,6 @@ while :; do
cmd.exe /c mklink %APPDATA%\\Mozilla\\Firefox\\Profiles\\"$profile"\\user.js "$root_win"\\firefox\\configs\\"$config"
done
;;
win-developer-mode)
powershell.exe start regedit -verb runas "$root_win\windows\developer-mode.reg"
;;
win-scancode-map)
powershell.exe start regedit -verb runas "$root_win\windows\scancode-map.reg"
;;
'')
break
;;

1
firefox/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/*.proxy

30
firefox/README.md Normal file
View File

@ -0,0 +1,30 @@
# Firefox
## `.gitignore`'d
- `configs/*` - files whose names are `+`-separated filenames of files from this directory - these will be constructed by concatenation from the base files, and will be symlinked to from various Firefox profiles' `user.js` files
- `*.proxy` - proxy auto-config files - these too can be referred to in the above `configs/*` files, without the `.proxy` extension
## `user.js` handling (Windows-specific)
Create `*.proxy` files containing proxy auto-config files.
Create empty `configs/*` files whose names are assembled by concatenating the names of templates in this directory (or `*.proxy` files without the `.proxy` extension) separated by `+`s.
There is a menu option in `config.sh` to generate (or regenerate) the `configs/*` files from their constituent templates, including adding the appropriate configuration to point to a particular `*.proxy` file.
There is also a menu option in `config.sh` for creating symlinks from various Firefox profiles' `user.js` files to the assembled `configs/*` files.
## Additional manual setup
For each profile:
- Change the [default search engine](about:preferences#search) to DuckDuckGo
- Current approximate complement of add-ons (varies by profile):
- [Buster: Captcha Solver for Humans](https://addons.mozilla.org/addon/buster-captcha-solver/)
- [Feedbro](https://addons.mozilla.org/addon/feedbroreader/)
- [Greasemonkey](https://addons.mozilla.org/addon/greasemonkey/)
- [Kee - Password Manager](https://addons.mozilla.org/addon/keefox/)
- [NoScript Security Suite](https://addons.mozilla.org/addon/noscript/)
- [RSSPreview](https://addons.mozilla.org/addon/rsspreview/)
- [uBlock Origin](https://addons.mozilla.org/addon/ublock-origin/)

2
firefox/configs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/*
!/.gitignore

5
gcloud/README.md Normal file
View File

@ -0,0 +1,5 @@
# Google Cloud SDK
## `.gitignore`'d
- `config/*` - Google Cloud SDK configuration files

2
gcloud/config/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/*
!/.gitignore

1
git/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/github_token

28
git/README.md Normal file
View File

@ -0,0 +1,28 @@
# Git
## `.gitignore`'d
- `github_token` - GitHub Personal Access Token with read access to repos
## Scripts
- [`git clean-branches`](scripts/git-clean-branches) - delete local branches which track deleted remote branches
- [`git clean-config`](scripts/git-clean-config) - unset various local config values, so global config will be used
- [`git clean-dates`](scripts/git-clean-dates) - set commit dates of all commits in the given range to their authoring dates
- [`git clean-fork`](scripts/git-clean-fork) - assuming `origin` and `fork` remotes, resets default branch on `fork` to first commit on `origin`, deletes all other branches on `fork` that are present on `origin`, and deletes all tags on `fork`
- [`git clean-modes`](scripts/git-clean-modes) - reset all file modes to those in the repository
- [`git clean-mtime`](scripts/git-clean-mtime) - set a file's mtime to its most recent commit's author date
- [`git clean-pr`](scripts/git-clean-pr) - delete all `pr/` branches created by `git cpr`
- [`git clean-user`](scripts/git-clean-user) - set author and committer of all commits in the given range to the currently configured identity
- [`git cpr`](scripts/git-cpr) - checkout a PR from GitHub by id, and set up the local branch to track the appropriate branch on the appropriate fork
- [`git download-bundle`](scripts/git-download-bundle) - download a bundle file from a remote repository
- [`git index-list-skip`](scripts/git-index-list-skip) - list all files that have had `--skip-worktree` set on them
- [`git index-skip`](scripts/git-index-skip) - set `--skip-worktree` on a given file
- [`git index-unskip`](scripts/git-index-unskip) - set `--no-skip-worktree` on a given file
- [`git npm-add`](scripts/git-npm-add) - stage precisely the files that would be included in an npm package
- [`git track`](scripts/git-track) - set current branch to track given remote and branch, defaulting to same branch name
- [`git turbo-gc`](scripts/git-turbo-gc) - turbo garbage collect
## Git Credential Manager Core WSL/Windows interop
Copy [`wsl/git-credential-manager`](wsl/git-credential-manager) into the root of the Git for Windows installation, and symlink to it from the WSL `PATH`.

View File

@ -1,4 +1,4 @@
# KeePass Config
# KeePass
## Installed plugins

1
nodejs/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.npmrc

11
nodejs/README.md Normal file
View File

@ -0,0 +1,11 @@
## Node.js
## `.gitignore`'d
- `.npmrc` - npm credentials, config, etc.
## Scripts
- [`npma.sh`](scripts/npma.sh) - find the given binaries searching upwards through `node_modules` and output aliases for them, suitable for `>> ~/.bash_aliases`
- [`npmg.sh`](scripts/npmg.sh) - create a commit for a new version (if there are staged changed), and create and tag an otherwise dangling commit from HEAD that contains all of the files `npm publish` would
- [`npml.sh`](scripts/npml.sh) - find the `node_modules` where the given dependencies are used, search up further for directories defining them, and create symlinks

5
ssh/README.md Normal file
View File

@ -0,0 +1,5 @@
# SSH
## `.gitignore`'d
- `config/*` - SSH keys, config, etc.

2
ssh/config/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/*
!/.gitignore

13
tmux/README.md Normal file
View File

@ -0,0 +1,13 @@
# tmux
## Keybindings
The included [`.tmux.conf`](.tmux.conf) makes the following changes/additions to the default tmux keybindings:
- The prefix key is now `ctrl-a` (and `ctrl-a ctrl-a` is used to send `ctrl-a` to the console)
- Switching windows is done with `ctrl-alt-left/right` (no prefix key)
- Switching panes is done with `alt-left/right/up/down` (no prefix key)
- Splitting panes is done with `ctrl-a |` (horizontal) and `ctrl-a -` (vertical)
- Reloading `~/.tmux.conf` is done with `ctrl-a shift-r`
Mouse control is also enabled, and the terminal mode is set to `screen-256color`.

11
vscode/README.md Normal file
View File

@ -0,0 +1,11 @@
# VS Code
## Settings and keybindings
[`settings.json`](settings.json) and [`keybindings.json`](keybindings.json) are VS Code's configuration files.
## Local extension
[`local-extension`](local-extension) contains a local, unpublished extension.
Currently it contains syntax highlighting for Svelte, separated from the other behavior from the official extension.

5
win/README.md Normal file
View File

@ -0,0 +1,5 @@
# Windows
## Registry entries
These are `.reg` files for configuration changes to Windows.

22
wsl/README.md Normal file
View File

@ -0,0 +1,22 @@
# WSL
## Setup
Use [`install.cmd`](install.cmd) to set up a new WSL installation. Run without arguments for details.
# wsl-elevate
[`wsl-elevate`](wsl-elevate) is a script that should be added to the system's path (not just the current user's path). Sourcing it in a script will result in that script being automatically relaunched as `root`. It's needed for several of the scripts below.
## Scripts
- [`wsl-apt`](scripts/wsl-apt) - run `apt update`/`upgrade`/`install`/`remove`/`autoremove`/`autoclean`
- any package names given as arguments are treated as packages to `install`, except any prefixed with a `-` are treated as packages to `remove`
- [`wsl-expose-ports`](scripts/wsl-expose-ports) - expose one or more ports within WSL to the outside world
- this sets up a port proxy and a Windows firewall rule for each exposed port, and removes previous port proxies and firewall rules
- multiple ports can be specified, each with an optional external port: `1234` exposes port 1234 as 1234, `1234:5678` exposes port 5678 as 1234
- call without arguments to remove port proxies and firewall rules without creating new ones
- [`wsl-fix-clock`](scripts/wsl-fix-clock) - sync the WSL clock with the Windows clock
- [`wsl-fix-interop`](scripts/wsl-fix-interop) - fix `WSL_INTEROP` variable when it becomes incorrectly set
- [`wsl-services`](scripts/wsl-services) - start useful services not automatically started by WSL
- starts `procps` for `sysctl` configuration