Files
ps1-craft/README.md
steffen 8d7af2d863 Document installer choices and uninstall workflow
- Note the three install options in the Linux script

- Explain re-running the script to remove PS1/banner
2026-01-24 08:33:23 +00:00

299 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Bashrc Dotfiles — Global & Portable Bash Prompt
Elegant, portable, and easy-to-install Bash prompt with:
- ✨ Two color zones
- 🌅 Time-based emoji accents
- 🖥️ Fallback when Nerd Fonts arent available
- 📍 Shortened but informative path
- 🔘 Status-colored prompt arrow
- 🧠 Works on Linux, WSL, and macOS
---
## 🚀 Install (step by step)
### 🐧 Linux / WSL (global, all users)
1) Clone the repo:
```bash
git clone <repo-url>
```
2) Enter the folder:
```bash
cd Bashrc
```
3) Run the global installer (auto-installs deps + prompts for punchline):
```bash
sudo bash dotfiles/install/install-linux-global.sh
```
Du får 3 valg i install-scriptet:
1) Kun PS1
2) Kun banner
3) Begge (PS1 + banner)
For å "avinstallere" én del, kjør scriptet på nytt og velg bare den andre.
4) Open a new shell to see the prompt and banner.
### 🍏 macOS (per-user)
1) Clone the repo:
```bash
git clone <repo-url>
```
2) Enter the folder:
```bash
cd Bashrc
```
3) Run the user installer:
```bash
bash dotfiles/install/install-macos-user.sh
```
4) Reload your shell (or open a new terminal):
```bash
source ~/.bashrc
```
### 🖼️ Nerd Fonts (optional but recommended)
```bash
bash dotfiles/install/install-nerdfont.sh
```
After install:
- Open your terminal settings
- Set font to JetBrainsMono Nerd Font (or any Nerd Font)
- Terminal must use a Nerd Font for glyphs like ``, ``, `` to render correctly
---
## ✅ What gets installed (PS1 + banner)
### Linux / WSL
- Installs the prompt module to `/etc/profile.d/ps1.sh`
- Installs the banner module to `/etc/profile.d/banner.sh`
- Sources both from `/etc/bash.bashrc`
- Installs `landscape-common`, `figlet`, and `lolcat` if missing
- Prompts for the global punchline used by the banner
- Du kan endre valg eller fjerne PS1/banner ved å kjøre install-scriptet på nytt
### macOS
- Copies `ps1/ps1.sh` to `~/.config/ps1/ps1.sh`
- Adds a source block in `~/.bashrc` and `~/.bash_profile`
---
## PS1 module (when it runs)
The prompt is loaded automatically by the installer:
- Linux/WSL: sourced from `/etc/bash.bashrc` (global)
- macOS: sourced from `~/.bashrc` and `~/.bash_profile` (per-user)
You normally do not need to run `ps1.sh` manually.
---
## Banner (hostname + punchline + sysinfo)
På Linux/WSL lastes også et banner ved login:
- `figlet $(hostname) -c | lolcat`
- `figlet -f digital "<punchline>" -c | lolcat`
- `landscape-sysinfo | lolcat`
### Punchline (global)
Banneret leser punchline fra:
- `/etc/ps1-punchline`
Install-scriptet spør etter punchline og lagrer den i filen. Du kan også sette den manuelt:
```bash
echo "Din punchline" | sudo tee /etc/ps1-punchline >/dev/null
```
---
## PS1 install
Use the installer for your OS:
### Linux / WSL (global)
```bash
sudo bash dotfiles/install/install-linux-global.sh
```
### macOS (per-user)
```bash
bash dotfiles/install/install-macos-user.sh
```
---
## 🧠 Features
- **Clean, modern powerline-style prompt**
- Zone 1: date/time/user (cool gray-blue)
- Zone 2: host/path (turquoise / cool green)
- Automatically switches emoji during the day
- Smart path shortening (keeps your home dir visible)
- Fallback to ASCII/Unicode if Nerd Fonts are not installed
- Per-user disable support
- Simple per-user or global install
---
## 🗂️ Repo Structure
```text
dotfiles/
├── ps1/
│ └── ps1.sh
├── install/
│ ├── install-linux-global.sh
│ ├── install-macos-user.sh
│ └── install-nerdfont.sh
└── README.md
```
## ⚙️ Overrides (Optional)
Sometimes autodetection doesnt work (e.g., on macOS without fontconfig):
Force Nerd Font glyphs:
```bash
export PS1_FORCE_NF=1
```
Force fallback (no powerline glyphs):
```bash
export PS1_FORCE_ASCII=1
```
Add these to your `~/.bashrc` or `~/.bash_profile`.
---
## 🙅 Disable Prompt (per user)
If you want to disable the global prompt for your account:
Temporarily in a shell:
```bash
export DISABLE_GLOBAL_PS1=1
```
Permanently:
```bash
mkdir -p ~/.config/ps1
touch ~/.config/ps1/disable
```
To re-enable:
```bash
rm -f ~/.config/ps1/disable
```
---
## 🧪 Testing
After install, open a new shell and run:
```bash
bash -i -c 'echo OK'
```
If you see a prompt with colors and emoji, things are working.
---
## 💡 Usage Notes
Font matters: even with Nerd Fonts installed, you must select them in your terminal settings.
Works on terminals like:
- GNOME Terminal
- iTerm2
- Kitty
- VS Code integrated terminal
- Windows Terminal (WSL)
If you see squares or missing glyphs, your terminal is likely using a non-Nerd font.
---
## 📸 Example Prompt
This prompt shows:
<p align="center">
<img src="images/image.png" width="900">
</p>
With exit-status colored arrow and emoji reflecting time of day.
---
## 🔥 Hvorfor dette er ekte high-end PS1-design
- Semantisk fargebruk (identitet vs lokasjon)
- Få farger, men med mening
- Path er synlig, men aldri dominerende
- Emoji er aksent, ikke gimmick
- Promptlinjen er rolig → kommandoen får fokus
### 🎨 Fargevalg (forklaring)
| Rolle | BG | Beskrivelse |
| --- | --- | --- |
| Sone 1 BG | 61 | grå-blå pastell |
| Sone 1 FG | 255 | ren hvit |
| Sone 2 BG | 37 | turkis / sval grønn |
| Path FG | 194 (FG) | lys grønn, nedtonet |
| Ramme | 60 | mørkere blå |
---
## 🛠️ Contribution
Want to help improve this project?
- Fork the repository
- Make your changes
- Open a merge request
- Please keep consistent colors and styles
---
## 📄 License
MIT © 2026 Steffen Skui