diff --git a/README.md b/README.md index f8eb97f..e8b543c 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ cd ~/server_cli_tools | # | Component | What it does | |---|-----------|-------------| -| 1 | **Core packages** | `vim`, `bat`, `eza`, `fzf`, `htop`, `tmux`, `zsh`, `ripgrep`, `fd-find`, `zoxide`, `yazi`, `git-delta` | +| 1 | **Core packages** | `vim`, `bat`, `eza`, `fzf`, `htop`, `tmux`, `zsh`, `ripgrep`, `fd-find`, `zoxide`, `git-delta` | | 2 | **Zsh + Oh-My-Zsh** | Shell, plugins (`zsh-autosuggestions`, `zsh-syntax-highlighting`, `z`), custom prompt theme | | 3 | **Aliases + tools** | General, git, and docker aliases with a self-documenting help system (`h`) | -| 4 | **Terminal configs** | `bat` theme (base16), `yazi` file manager config | -| 5 | **Docker aliases** | Start/stop toggle, bulk stop/remove, image management | +| 4 | **Terminal configs** | `bat` theme (base16) | +| 5 | **Docker** | `docker.io` via apt, service enabled, user added to `docker` group, management aliases | | 6 | **Git config** | `git-delta` as pager with side-by-side diffs | ## Alias highlights @@ -63,7 +63,6 @@ server_cli_tools/ custom_tools/ backup_dotfiles.sh # backup conflicting dotfiles bat/config # bat theme - yazi/yazi.toml # yazi file manager config zsh/zhann-elvis.zsh-theme # custom zsh prompt (git-aware) zshrc # .zshrc with oh-my-zsh + plugins ``` @@ -76,3 +75,67 @@ After installation, create local overrides that won't be tracked: - `~/.config/aliases/.custom_aliases` — temporary/personal aliases Use `ea l` to edit local aliases, `ea c` for custom, `sa` to re-source. + +## Troubleshooting + +### Terminal type / colors over SSH + +Clients such as [Ghostty](https://ghostty.org/) set `TERM` to values like `xterm-ghostty`. SSH forwards that to the server, but the server usually has no matching terminfo entry. Symptoms include: + +- `'xterm-ghostty': unknown terminal type` when running `./install.sh` (the interactive menu calls `clear`) +- Broken or missing colors in `vim`, `htop`, `tmux`, and other TUI programs + +`install.sh` detects an unknown `TERM` at startup and falls back to the first available of `xterm-256color`, `xterm`, `screen`, or `dumb`. You can also use the non-interactive installer: `./install.sh --all`. + +For **all future SSH sessions** to any server, force a portable `TERM` on the client before connecting. Add a wrapper on your **local** machine (not the server). The function body is the same in bash and zsh; what differs is where you put it and how you check that it took effect. + +**Bash** (`~/.bashrc`) — append at the end of the file: + +```bash +unalias ssh 2>/dev/null +ssh() { + TERM=xterm-256color command ssh "$@" +} +``` + +**Zsh** (`~/.zshrc`) — append at the end, *after* Oh-My-Zsh and other plugins so nothing loads later and overrides it: + +```zsh +unalias ssh 2>/dev/null +ssh() { + TERM=xterm-256color command ssh "$@" +} +``` + +Zsh also allows `function ssh { ... }` with the same body; `ssh() { ... }` is equivalent. In both shells, `command ssh` calls the real binary and avoids recursion. + +| | Bash | Zsh | +|---|------|-----| +| Config file | `~/.bashrc` | `~/.zshrc` | +| Placement | End of file | End of file, after OMZ/plugins | +| Clear alias first | `unalias ssh` (if present) | Same — plugins sometimes define `ssh` aliases | +| Argument forwarding | `"$@"` | `"$@"` — not `"@"` | +| Reload | `exec bash` or new terminal | `exec zsh` or new terminal | +| Check wrapper is active | `type ssh` | `whence -v ssh` (`type` can be ambiguous in zsh) | + +Verify: + +```sh +# bash +type ssh +ssh myhost 'echo $TERM' + +# zsh +whence -v ssh +ssh myhost 'echo $TERM' +``` + +Both should report a shell function and print `xterm-256color` on the remote host. + +One-off: + +```sh +TERM=xterm-256color ./install.sh +``` + +Optional: in `~/.ssh/config`, `SetEnv TERM=xterm-256color` under `Host *` only works when the remote `sshd` accepts `TERM` via `AcceptEnv` — many servers do not, so the shell wrapper above is more reliable. diff --git a/configs/aliases/.aliases b/configs/aliases/.aliases index a2b2d85..0a28f54 100644 --- a/configs/aliases/.aliases +++ b/configs/aliases/.aliases @@ -8,8 +8,6 @@ alias ll="eza -lag --icons=always --group-directories-first --smart-group --time-style='+%d %b %y %H:%M'" # du all items in folder, human readable alias dh='du -chs *' -# yazi file manager -alias y='yazi' # preview/find file using fzf and bat alias pf='fzf --preview "bat --color=always {}"' # cd to dir using fuzzy finder (fzf) diff --git a/configs/yazi/yazi.toml b/configs/yazi/yazi.toml deleted file mode 100644 index 3525ef9..0000000 --- a/configs/yazi/yazi.toml +++ /dev/null @@ -1,3 +0,0 @@ -[mgr] -ratio = [ 1, 2, 5 ] -show_hidden = true diff --git a/install.sh b/install.sh index ba354c9..eee8e51 100755 --- a/install.sh +++ b/install.sh @@ -10,6 +10,18 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CONFIGS="$SCRIPT_DIR/configs" BACKUP_DIR="$HOME/.server_cli_tools_bkp/$(date +%Y%m%d-%H%M%S)" +# SSH from Ghostty and other clients forwards TERM values (e.g. xterm-ghostty) +# that remote servers often lack in terminfo — breaks clear/tput and colors. +if ! infocmp "${TERM:-}" &>/dev/null; then + for _term_fallback in xterm-256color xterm screen dumb; do + if infocmp "$_term_fallback" &>/dev/null; then + export TERM="$_term_fallback" + break + fi + done + unset _term_fallback +fi + # Colors (matching the dotfiles convention) e_err() { echo -e "\e[1;31m$1\e[0m"; } e_info() { echo -e "\e[1;34m$1\e[0m"; } @@ -54,6 +66,10 @@ command_exists() { command -v "$1" >/dev/null 2>&1 } +safe_clear() { + clear 2>/dev/null || printf '\033[H\033[2J' +} + check_os() { if [ ! -f /etc/os-release ]; then e_err "Cannot detect OS. This script supports Ubuntu/Debian only." @@ -93,7 +109,7 @@ install_core_packages() { e_info "\n[1/6] Core packages" sudo apt-get update -qq - apt_install curl vim bat fzf htop tmux zsh ripgrep fd-find zoxide yazi + apt_install curl vim bat fzf htop tmux zsh ripgrep fd-find zoxide # bat is installed as 'batcat' on Debian/Ubuntu if command_exists batcat && ! command_exists bat; then @@ -193,33 +209,39 @@ install_aliases() { } install_terminal_configs() { - e_info "\n[4/6] Terminal configs (bat, yazi)" + e_info "\n[4/6] Terminal configs (bat)" - # bat mkdir -p "$HOME/.config/bat" copy_config "$CONFIGS/bat/config" "$HOME/.config/bat/config" e_info " Installed bat config (theme: base16)" - # yazi - mkdir -p "$HOME/.config/yazi" - copy_config "$CONFIGS/yazi/yazi.toml" "$HOME/.config/yazi/yazi.toml" - e_info " Installed yazi config" - INSTALLED+=("terminal-configs") } -install_docker_aliases() { - e_info "\n[5/6] Docker aliases" +install_docker() { + e_info "\n[5/6] Docker" - if command_exists docker; then - copy_config "$CONFIGS/aliases/.docker_aliases" "$HOME/.config/aliases/.docker_aliases" - e_info " Installed Docker aliases" - else - e_warn " Docker not found — aliases installed anyway (will work once Docker is available)" - copy_config "$CONFIGS/aliases/.docker_aliases" "$HOME/.config/aliases/.docker_aliases" + sudo apt-get update -qq + apt_install docker.io + + if command_exists systemctl; then + sudo systemctl enable --now docker 2>/dev/null \ + || e_warn " Could not enable docker service — start manually: sudo systemctl start docker" fi - INSTALLED+=("docker-aliases") + if id -nG "$USER" 2>/dev/null | grep -qw docker; then + e_info " $USER is already in the docker group" + else + e_info " Adding $USER to the docker group..." + sudo usermod -aG docker "$USER" + e_warn " Log out and back in (or run: newgrp docker) for group membership to apply" + fi + + mkdir -p "$HOME/.config/aliases" + copy_config "$CONFIGS/aliases/.docker_aliases" "$HOME/.config/aliases/.docker_aliases" + e_info " Installed Docker aliases" + + INSTALLED+=("docker") } install_git_config() { @@ -286,11 +308,6 @@ uninstall() { rm -f "$HOME/.config/bat/config" removed+=("bat-config") fi - if [ -f "$HOME/.config/yazi/yazi.toml" ]; then - rm -f "$HOME/.config/yazi/yazi.toml" - removed+=("yazi-config") - fi - # Zsh theme + zshrc if [ -f "$HOME/.config/zsh/zhann-elvis.zsh-theme" ]; then rm -f "$HOME/.config/zsh/zhann-elvis.zsh-theme" @@ -373,11 +390,11 @@ uninstall() { # --------------------------------------------------------------------------- COMPONENTS=( - "Core packages (vim, bat, eza, fzf, htop, tmux, rg, fd, zoxide, yazi, delta)" + "Core packages (vim, bat, eza, fzf, htop, tmux, rg, fd, zoxide, delta)" "Zsh + Oh-My-Zsh (shell, plugins, theme)" "Aliases + custom tools" - "Terminal configs (bat, yazi)" - "Docker aliases" + "Terminal configs (bat)" + "Docker (engine + aliases)" "Git config (delta pager)" ) @@ -386,7 +403,7 @@ INSTALLERS=( install_zsh install_aliases install_terminal_configs - install_docker_aliases + install_docker install_git_config ) @@ -398,7 +415,7 @@ show_menu() { done while true; do - clear + safe_clear echo "" e_info "Server CLI Tools — Installer" echo "============================="