first commit2
This commit is contained in:
1 parent
52dc8504bd
commit
7aa7c7e765
3 files changed
No files matched your search
@@ -0,0 +1,144 @@
|
||||
# dotfiles — zsh + Oh My Zsh one-liner
|
||||
|
||||
Installs **zsh**, **Oh My Zsh**, three community plugins, and a curated `~/.zshrc`
|
||||
(backing up whatever was there) — in one command, straight from this repo.
|
||||
|
||||
```bash
|
||||
bash <(curl -Lso- https://ad.derty.sbs/leo/dotfiles/raw/branch/main/install.sh)
|
||||
```
|
||||
|
||||
Only `bash`, `curl` and one of `apt/dnf/yum/pacman/zypper/apk/brew` are required.
|
||||
Everything else is fetched by the script.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Purpose |
|
||||
| ------------ | -------------------------------------------------------------------- |
|
||||
| `install.sh` | The installer. Also the **single source of truth** for the config. |
|
||||
| `zshrc` | The config as a plain file, generated by `install.sh --config-only`. |
|
||||
| `README.md` | This file. |
|
||||
|
||||
`install.sh` embeds the `.zshrc` in a quoted heredoc, so the script never needs a
|
||||
second download — it works even if the repo goes away after you copied the URL.
|
||||
`zshrc` is kept in the repo only so people can read or copy the config alone. If
|
||||
you edit `install.sh`, regenerate the mirror with:
|
||||
|
||||
```bash
|
||||
./install.sh --config-only > zshrc
|
||||
```
|
||||
|
||||
## What it does
|
||||
|
||||
1. Detects the package manager and installs whatever is missing of `zsh`, `git`, `curl`.
|
||||
2. Clones `ohmyzsh/ohmyzsh` into `~/.oh-my-zsh` (or `git pull`s it if already there).
|
||||
3. Clones `zsh-autosuggestions`, `zsh-syntax-highlighting`, `zsh-completions`
|
||||
into `~/.oh-my-zsh/custom/plugins`.
|
||||
4. Writes `~/.zshrc`, first moving any existing one to
|
||||
`~/.zshrc.backup.YYYYmmdd-HHMMSS`. Files it generated itself are replaced in
|
||||
place without a new backup (detected by the `managed-by: install.sh` marker).
|
||||
5. Adds the zsh binary to `/etc/shells` if needed and runs `chsh -s`.
|
||||
6. Never touches `~/.zshrc.local` — that is yours, and is sourced at the end of
|
||||
every shell.
|
||||
|
||||
The script is idempotent: run it again any time to update.
|
||||
|
||||
## Flags
|
||||
|
||||
Append them to the one-liner, e.g. `bash <(curl -Lso- …) --no-chsh`:
|
||||
|
||||
| Flag | Effect |
|
||||
| -------------- | --------------------------------------------------- |
|
||||
| `-y`, `--yes` | no confirmation prompt |
|
||||
| `-n`, `--dry-run` | print every action, change nothing |
|
||||
| `--no-chsh` | leave the login shell alone |
|
||||
| `--no-plugins` | skip the three zsh-users plugins (slow mirror / offline) |
|
||||
| `--config-only`| print the bundled `~/.zshrc` to stdout and exit |
|
||||
| `-h`, `--help` | usage |
|
||||
|
||||
Also useful when piping instead of process substitution (bash eats `--flags`
|
||||
right after `-s`, so the `--` is required):
|
||||
|
||||
```bash
|
||||
curl -Lso- https://ad.derty.sbs/leo/dotfiles/raw/branch/main/install.sh | bash -s -- -y
|
||||
```
|
||||
|
||||
Environment:
|
||||
|
||||
- `GITHUB_MIRROR` — proxy prefix for the clones, e.g.
|
||||
`GITHUB_MIRROR=https://ghfast.top/https://github.com`
|
||||
- `ZSH_THEME` — theme, default `robbyrussell`
|
||||
- `DOTFILES_URL` — base URL printed in `--help`
|
||||
|
||||
## Publishing to your own Gitea
|
||||
|
||||
The one-liner above assumes repo `leo/dotfiles`, branch `main`, and file
|
||||
`install.sh` at the repo root. Gitea serves raw files at
|
||||
`https://<domain>/<owner>/<repo>/raw/branch/<branch>/<path>`.
|
||||
|
||||
```bash
|
||||
cd dotfiles
|
||||
git init -b main
|
||||
git add install.sh zshrc README.md
|
||||
git commit -m "zsh + oh-my-zsh installer"
|
||||
git remote add origin https://ad.derty.sbs/leo/dotfiles.git
|
||||
git push -u origin main
|
||||
```
|
||||
|
||||
The repo must be **public**, otherwise the anonymous `curl` gets a login page
|
||||
instead of the script (a private repo would need a token in the URL — don't do
|
||||
that in a copy-paste one-liner).
|
||||
|
||||
Then check it before trusting it:
|
||||
|
||||
```bash
|
||||
curl -fsS -L https://ad.derty.sbs/leo/dotfiles/raw/branch/main/install.sh | head -5
|
||||
```
|
||||
|
||||
### Optional: a `git.io`-style short URL
|
||||
|
||||
`git.io` was shut down in 2022, so the closest replacement is a redirect on your
|
||||
own host. With nginx on `ad.derty.sbs`:
|
||||
|
||||
```nginx
|
||||
location = /zsh {
|
||||
return 302 https://ad.derty.sbs/leo/dotfiles/raw/branch/main/install.sh;
|
||||
}
|
||||
```
|
||||
|
||||
`curl -L` follows it, so the short form works unchanged:
|
||||
|
||||
```bash
|
||||
bash <(curl -Lso- https://ad.derty.sbs/zsh)
|
||||
```
|
||||
|
||||
## Uninstall
|
||||
|
||||
```bash
|
||||
chsh -s /bin/bash # or /bin/sh
|
||||
mv ~/.zshrc.backup.* ~/.zshrc 2>/dev/null # restore your old config
|
||||
rm -rf ~/.oh-my-zsh
|
||||
rm ~/.zshrc
|
||||
# optional: remove the package
|
||||
# Debian/Ubuntu: sudo apt-get remove zsh
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**`zsh compinit: insecure directories`** — Oh My Zsh refuses to complete when a
|
||||
directory in `fpath` is group/world-writable. Fix the permissions rather than
|
||||
disabling the check:
|
||||
|
||||
```bash
|
||||
compaudit | xargs chmod g-w,o-w
|
||||
```
|
||||
|
||||
**Clones time out** — set `GITHUB_MIRROR`, or run with `--no-plugins` and add the
|
||||
plugins later.
|
||||
|
||||
**`your shell is not in /etc/shells`** — the script appends it via `sudo tee`;
|
||||
if that failed, add the `command -v zsh` path to `/etc/shells` by hand and re-run
|
||||
`chsh -s $(command -v zsh)`.
|
||||
|
||||
**Wrong config after reinstall** — your old file is at
|
||||
`~/.zshrc.backup.<timestamp>`; diff it against the new one and move anything you
|
||||
still want into `~/.zshrc.local`.
|
||||
Reference in new issue
Block a user