fix: improve VSCode terminal compatibility in .zshrc; update README for device-aware setup and troubleshooting

- Add VSCode detection and fallback keybinds to .zshrc for robust navigation in integrated terminals
- Expand README with device profile logic, troubleshooting, and module reference

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
This commit is contained in:
Martin Büchler 2025-08-08 14:33:00 +02:00
parent d9bebb71ac
commit cbe3ff94ac
2 changed files with 101 additions and 37 deletions

86
.zshrc
View File

@ -130,39 +130,63 @@ alias ...="cd ../.."
# Robust keybinds for navigation and editing (support most terminals)
# =====================
# Use terminfo for portability
typeset -g -A key
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Delete]="${terminfo[kdch1]}"
key[Up]="${terminfo[kcuu1]}"
key[Down]="${terminfo[kcud1]}"
key[Left]="${terminfo[kcub1]}"
key[Right]="${terminfo[kcuf1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"
key[Shift-Tab]="${terminfo[kcbt]}"
# VSCode terminal compatibility detection
export IS_VSCODE_TERM=0
if [[ "$TERM_PROGRAM" == "vscode" ]] || [[ -n "$VSCODE_IPC_HOOK_CLI" ]]; then
export IS_VSCODE_TERM=1
fi
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete
if (( IS_VSCODE_TERM )); then
# VSCode terminal: use standard escape sequences for keybinds
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
bindkey '^[[2~' overwrite-mode
bindkey '^[[3~' delete-char
bindkey '^[[5~' beginning-of-buffer-or-history
bindkey '^[[6~' end-of-buffer-or-history
bindkey '^[[A' up-line-or-history
bindkey '^[[B' down-line-or-history
bindkey '^[[C' forward-char
bindkey '^[[D' backward-char
bindkey '^[[1;5D' backward-word # Ctrl+Left
bindkey '^[[1;5C' forward-word # Ctrl+Right
bindkey '^[[1;3D' backward-word # Alt+Left
bindkey '^[[1;3C' forward-word # Alt+Right
else
# Use terminfo for portability
typeset -g -A key
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Delete]="${terminfo[kdch1]}"
key[Up]="${terminfo[kcuu1]}"
key[Down]="${terminfo[kcud1]}"
key[Left]="${terminfo[kcub1]}"
key[Right]="${terminfo[kcuf1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"
key[Shift-Tab]="${terminfo[kcbt]}"
# Common escape sequences for Ctrl/Alt + Arrow keys (Alacritty, xterm, etc.)
bindkey '^[[1;5D' backward-word # Ctrl+Left
bindkey '^[[1;5C' forward-word # Ctrl+Right
bindkey '^[Od' backward-word # Ctrl+Left (alternate)
bindkey '^[Oc' forward-word # Ctrl+Right (alternate)
bindkey '^[[1;3D' backward-word # Alt+Left
bindkey '^[[1;3C' forward-word # Alt+Right
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete
# Common escape sequences for Ctrl/Alt + Arrow keys (Alacritty, xterm, etc.)
bindkey '^[[1;5D' backward-word # Ctrl+Left
bindkey '^[[1;5C' forward-word # Ctrl+Right
bindkey '^[Od' backward-word # Ctrl+Left (alternate)
bindkey '^[Oc' forward-word # Ctrl+Right (alternate)
bindkey '^[[1;3D' backward-word # Alt+Left
bindkey '^[[1;3C' forward-word # Alt+Right
fi
# Already present: Alt+b/f for word movement
# bindkey '^[b' backward-word

View File

@ -2,10 +2,12 @@
This repository manages your personal dotfiles and a modular, Wayland-ready desktop environment for Arch Linux using `paru`.
---
## Features
- Modular setup: each aspect (packages, symlinks, shell, Neovim, Hyprland, sound, browsers, devtools, etc.) is handled by its own script in `modules/`.
- All dotfiles and app configs are version-controlled and symlinked to your home directory.
- Device-aware: uses `$DOTFILES_DEVICE` and `$HOSTNAME` to select device-specific config fragments (e.g., laptop/desktop, monitor layouts).
- Out-of-the-box integration for Hyprland, Waybar, Rofi, Mako, Alacritty, wlogout, and more.
- Modern sound stack (PipeWire, WirePlumber, pavucontrol, etc.).
- Volume notifications: see current volume as a Mako popup at the bottom center when changed.
@ -13,7 +15,9 @@ This repository manages your personal dotfiles and a modular, Wayland-ready desk
- Brave browser always launches on workspace 10 and autostarts with Hyprland.
- TTY/console uses German nodeadkeys layout (`de-latin1-nodeadkeys`).
- Devtools module installs git, Python, Node.js, Docker, VS Code, opencode-bin, and more.
- Easily extensible: add new modules or configs as needed.
- Easily extensible: add new modules, fragments, or configs as needed.
---
## Setup
@ -27,30 +31,64 @@ This repository manages your personal dotfiles and a modular, Wayland-ready desk
./setup.sh
```
When you run `setup.sh`, you will be prompted to select your device profile (`laptop` or `desktop`).
This ensures that device-specific configs (e.g., battery, backlight, touchpad, monitor layout) are applied correctly for your hardware.
You can also set the environment variable `DOTFILES_DEVICE` to skip the prompt:
When you run `setup.sh`, your device profile is detected via `host-profiles.conf` (mapping `$HOSTNAME` to `$DOTFILES_DEVICE`, e.g., `laptop` or `desktop`).
This ensures that device-specific configs (battery, backlight, touchpad, monitor layout, etc.) are applied correctly for your hardware.
You can also set the environment variable manually to override:
```sh
DOTFILES_DEVICE=desktop ./setup.sh
```
The script will install all required packages and symlink dotfiles and configs (including everything in `.config/`) to your home directory, using the correct device-specific fragments for Hyprland and Waybar.
The script will install all required packages and symlink dotfiles and configs (including everything in `.config/`) to your home directory, using the correct device-specific fragments for Hyprland, Waybar, and more.
---
## Customization
## Customization & Extending
- Add new dotfiles to the repo root (e.g., `.zshrc`, `.tmux.conf`).
- Place app configs in `.config/` (e.g., `.config/hypr/hyprland.conf`).
- Add or edit modules in the `modules/` directory to automate more setup steps.
- To add custom scripts, place them in `.local/bin/` in the repo; they will be symlinked to `~/.local/bin/`.
- To add browsers, edit `modules/06-browsers.sh` (Chrome, Firefox, Brave supported out of the box).
- To add devtools, edit `modules/50-devtools.sh` (includes VS Code, opencode-bin, lazygit, etc.).
- To add new device types (e.g., tablet, server), update `host-profiles.conf` and add corresponding config fragments (e.g., `hypridle-tablet.conf`).
- To add new fragment types, extend the `fragment_types` array in `modules/02-symlinks.sh`.
---
## Requirements
- Arch Linux
- [paru](https://github.com/Morganamilo/paru) (will be installed automatically if missing)
- For TTY keymap: `kbd` package (should be present on most systems)
---
## Quick Reference: Main Modules
| Module | Purpose |
|-----------------------|-----------------------------------------|
| 01-packages.sh | Base packages (shell, tools, etc.) |
| 02-symlinks.sh | Symlinks dotfiles/configs, device-aware |
| 03-shell.sh | Shell setup (Zsh, keymap) |
| 04-nvim.sh | Neovim (AstroNvim) setup |
| 05-sound.sh | Sound stack (PipeWire, etc.) |
| 06-hyprland.sh | Hyprland, Waybar, Rofi, etc. |
| 07-browsers.sh | Browsers (Chrome, Firefox, Brave) |
| 50-devtools.sh | Devtools (git, VS Code, etc.) |
| 99-postinstall.sh | Post-install steps |
---
## Troubleshooting
- **Missing device-specific fragment:** If you see a warning about a missing fragment (e.g., `hypridle-laptop.conf`), create the file in `.config/hypr/includes/` or update your `host-profiles.conf` mapping.
- **Symlink warnings:** If a non-empty directory exists where a symlink should be, the script will warn and skip removal for safety. Manually back up and remove if needed.
- **Package install errors:** Ensure your Arch system is up to date and AUR is reachable. Rerun `setup.sh` after fixing network or package issues.
- **Updating dotfiles:** Pull the latest changes and re-run `./setup.sh` to sync configs and packages.
---
## Safety & Idempotence
- All scripts are safe to re-run and will not overwrite user files unintentionally.
- Symlinking logic only removes symlinks or empty directories; non-empty directories are preserved with a warning.
---
## Notable Integrations & Tips
- **Browsers:** Chrome, Firefox, and Brave are installed via the browser module. Brave autostarts and is always on workspace 10.
@ -61,5 +99,7 @@ The script will install all required packages and symlink dotfiles and configs (
- **No official Teams/Outlook client:** Use the web app or AUR wrappers for best compatibility.
- **TortoiseGit alternative:** Use GitKraken, Sublime Merge, SmartGit, or lazygit for graphical Git workflows.
---
## License
MIT