# 🌡️ temperatures — an Oh My Zsh plugin for CPU/GPU temps A lightweight, zero-dependency plugin that shows your machine’s **CPU** and (optionally) **GPU** temperatures directly in your Zsh prompt. Originally designed for Raspberry Pi but works on any Linux system exposing `/sys/class/thermal/`. Perfect for quick system health checks — no `watch`, no `htop`, just glance at your prompt. --- ## 🚀 Features - 📊 Displays **CPU** and **GPU** temperatures in °C or °F - 🎨 Auto-colorizes temperatures (green / yellow / red) based on thresholds - ⚙️ User-configurable decimals, format, units, and position - ⚡ Lightweight (no polling daemon; reads on prompt render) - 🧠 Smart caching to keep your prompt snappy - 🔁 Resilient to `source ~/.zshrc` reloads (auto-reattaches) - 🧩 Compatible with any theme (manual or auto placement) --- ## 🧰 Installation ### Option 1 — Oh My Zsh custom plugin (recommended) ```bash git clone https://github.com/groberth/temperatures-zsh "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/temperatures-zsh" ``` Then in your `~/.zshrc`: ```zsh plugins+=(temperatures-zsh) # optional configuration below ``` Reload your shell: ```bash exec zsh ``` ### Option 2 — Manual sourcing (without Oh My Zsh) ```bash git clone https://github.com/groberth/temperatures-zsh ~/.zsh/temperatures-zsh source ~/.zsh/temperatures-zsh/temperatures-zsh.plugin.zsh ``` Add `$(temperatures_prompt)` anywhere in your `PROMPT` or `RPROMPT`. --- ## ⚙️ Configuration All options are set via environment variables **before** the plugin loads (usually in `.zshrc`). Each has a default, so you can override only what you need. | Variable | Default | Description | |-----------|----------|-------------| | **`TEMPERATURES_AUTO`** | `true` | Whether to automatically inject the temperature display into your prompt. Set to `false` if you want to place it manually in your theme. | | **`TEMPERATURES_POSITION`** | `right` | Position when auto-inserting. `right` puts it in `RPROMPT`, `left` prepends it to `PROMPT`. | | **`TEMPERATURES_UNIT`** | `C` | Unit of measurement — `C` for Celsius or `F` for Fahrenheit. | | **`TEMPERATURES_DECIMALS`** | `1` | Number of decimal places (e.g. `0` for integers, `2` for high precision). | | **`TEMPERATURES_POLL_INTERVAL`** | `2` | Number of seconds to cache readings between prompt draws (performance trade-off). | | **`TEMPERATURES_FORMAT`** | `CPU:%s°%s GPU:%s°%s` | `printf`-style format string (`cpu, unit, gpu, unit`). Collapses gracefully if GPU is disabled/unavailable. | | **`TEMPERATURES_THRESHOLDS`** | `50 70` | Two numeric thresholds (in °C) that separate low → medium → high temperature coloring. | | **`TEMPERATURES_COLOR_LOW`** | `%F{green}` | Zsh color for “cool” temperatures (below first threshold). | | **`TEMPERATURES_COLOR_MED`** | `%F{yellow}` | Color for medium temperatures. | | **`TEMPERATURES_COLOR_HIGH`** | `%F{red}` | Color for hot temperatures (above second threshold). | | **`TEMPERATURES_SHOW_GPU`** | `auto` | Controls GPU reading. `auto` enables only if `vcgencmd` exists, `true` always tries, `false` disables. | --- ## 🧩 Manual usage (themes & Powerlevel10k) You can manually insert the output anywhere in your prompt: ```zsh RPROMPT='$(temperatures_prompt) %~' ``` ### Powerlevel10k integration Add this to `~/.p10k.zsh`: ```zsh function prompt_temperatures() { local s="$(temperatures_prompt)" [[ -n "$s" ]] || return p10k segment -t "$s" } POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=(temperatures-zsh) ``` --- ## 🧪 Example configuration ```zsh # ~/.zshrc plugins+=(temperatures-zsh) # show in °F with no decimals TEMPERATURES_UNIT=F TEMPERATURES_DECIMALS=0 # make it appear on the left of the prompt TEMPERATURES_POSITION=left # longer cache for faster prompts TEMPERATURES_POLL_INTERVAL=5 # hide GPU TEMPERATURES_SHOW_GPU=false ``` **Result:** ``` CPU:118°F ~/projects ``` --- ## 🛠️ Requirements - **CPU:** any Linux system exposing `/sys/class/thermal/thermal_zone0/temp` - **GPU (optional):** Raspberry Pi or similar, with `vcgencmd` in PATH - **Shell:** Zsh ≥ 5.0 - **Framework:** optional (works with or without Oh My Zsh) --- ## 🧾 License MIT © 2025 Groberth See the [LICENSE](./LICENSE) file for details.