Auf macOS (Homebrew) fehlt die 'gnu' Cowfile, was beim Login zu "Could not find cowfile for 'gnu'!" fuehrte. Cowfiles werden jetzt gegen die tatsaechlich installierten geprueft.
217 lines
8.2 KiB
Bash
217 lines
8.2 KiB
Bash
# ----------------------------------------------------------
|
|
# Zsh-Konfiguration fuer Rene (Linux / MacBook Pro)
|
|
# Oh My Zsh + Powerlevel10k + Micro
|
|
# ----------------------------------------------------------
|
|
|
|
# 1) Powerlevel10k Instant Prompt (muss sehr weit oben stehen)
|
|
# quiet: cowsay-Begruessung erzeugt Console-Output, Warnung unterdruecken
|
|
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
|
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
|
fi
|
|
|
|
# 1b) Secrets laden (API-Keys etc. — Datei liegt lokal, NICHT im Repo)
|
|
[[ -f "$HOME/.secrets" ]] && source "$HOME/.secrets"
|
|
|
|
# 2) Oh My Zsh Basis
|
|
export ZSH="$HOME/.oh-my-zsh"
|
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
|
|
|
plugins=(
|
|
git
|
|
zsh-syntax-highlighting
|
|
zoxide
|
|
)
|
|
|
|
source "$ZSH/oh-my-zsh.sh"
|
|
|
|
# 3) Powerlevel10k-Konfiguration
|
|
[[ -f "$HOME/.p10k.zsh" ]] && source "$HOME/.p10k.zsh"
|
|
|
|
# 4) Standard-Editor (lokal: micro, SSH: nicht erzwingen)
|
|
if [[ -z "$SSH_CONNECTION" ]]; then
|
|
export EDITOR="micro"
|
|
export VISUAL="micro"
|
|
fi
|
|
|
|
# 5) Pfade
|
|
export PATH="$HOME/bin:$HOME/.local/bin:$HOME/.npm-global/bin:$PATH"
|
|
|
|
# 6) Aliases
|
|
|
|
# ls-Varianten
|
|
alias ll='ls -lha'
|
|
alias la='ls -A'
|
|
alias l='ls -lh'
|
|
|
|
# Verzeichnisse
|
|
alias ..='cd ..'
|
|
alias ...='cd ../..'
|
|
alias ....='cd ../../..'
|
|
|
|
# Konfigdateien
|
|
alias zshconfig='micro ~/.zshrc'
|
|
alias p10kconfig='micro ~/.p10k.zsh'
|
|
|
|
# Git-Kurzbefehle
|
|
alias gs='git status'
|
|
alias ga='git add'
|
|
alias gc='git commit'
|
|
alias gp='git push'
|
|
alias gl='git log --oneline --graph --decorate'
|
|
alias gitcheck="~/git-check-all.sh --short"
|
|
alias gitupdate="~/git-update-all.sh"
|
|
alias cb="xclip -selection clipboard -o | sed 's/^ //' | xclip -selection clipboard -i"
|
|
alias fetch="fastfetch"
|
|
alias gitsync="~/git-sync-all.sh"
|
|
alias mac-sync="curl -fsSL https://git.motocamp.de/rene/dotfiles-rene/raw/branch/main/bin/git-sync-all.sh | bash"
|
|
|
|
# Ubuntu-Kompatibilitaet: fd und bat heissen dort anders
|
|
command -v fdfind &>/dev/null && ! command -v fd &>/dev/null && alias fd='fdfind'
|
|
command -v batcat &>/dev/null && ! command -v bat &>/dev/null && alias bat='batcat'
|
|
|
|
# 7) History
|
|
HISTFILE="$HOME/.zsh_history"
|
|
HISTSIZE=5000
|
|
SAVEHIST=5000
|
|
setopt HIST_IGNORE_DUPS
|
|
setopt HIST_IGNORE_SPACE
|
|
setopt SHARE_HISTORY
|
|
|
|
# 8) Zsh-Optionen
|
|
setopt AUTO_CD
|
|
|
|
# 9) Fenster-/Tab-Titel
|
|
precmd() { print -Pn "\e]0;%n@%m: %~\a" }
|
|
export COLORTERM=truecolor
|
|
|
|
# Cheat-Sheet: alle Tools, Aliases und Skripte auf einen Blick
|
|
tools() {
|
|
cat <<'TOOLS'
|
|
|
|
╔══════════════════════════════════════════════════════════════╗
|
|
║ Terminal Cheat-Sheet ║
|
|
╚══════════════════════════════════════════════════════════════╝
|
|
|
|
GIT
|
|
────────────────────────────────────────────────────────────────
|
|
gs git status
|
|
ga git add
|
|
gc git commit
|
|
gp git push
|
|
gl git log (oneline, graph)
|
|
gd git diff
|
|
gco git checkout
|
|
gb git branch
|
|
gitcheck Status aller Git-Repos pruefen
|
|
gitupdate alle Git-Repos pullen
|
|
gitsync alle Repos sync (push+pull)
|
|
mac-sync git-sync remote ausfuehren
|
|
|
|
PLATFORMIO
|
|
────────────────────────────────────────────────────────────────
|
|
pio run kompilieren
|
|
pio run -t upload flashen
|
|
pio device monitor seriellen Monitor oeffnen
|
|
pio run -t clean Build-Artefakte loeschen
|
|
pio lib install Bibliothek installieren
|
|
pio init --board <board> neues Projekt erstellen
|
|
|
|
NAVIGATION & DATEIEN
|
|
────────────────────────────────────────────────────────────────
|
|
z <pfad> zoxide: smart cd (lernt haeufige Pfade)
|
|
ll / la / l ls-Varianten (-lha / -A / -lh)
|
|
.. / ... / .... schnell hoch navigieren
|
|
eza modernes ls (Farben, Icons, Git-Status)
|
|
eza -la alle Dateien mit Details
|
|
eza -T Baumansicht
|
|
bat <datei> cat mit Syntax-Highlighting
|
|
fd <muster> schnelles find (z.B. fd '\.txt$')
|
|
rg <text> blitzschnelles grep (z.B. rg 'TODO' src/)
|
|
fzf Fuzzy-Finder (Ctrl+T Dateien, Ctrl+R History)
|
|
ncdu interaktive Festplattennutzung
|
|
duf schoene Uebersicht freier Speicherplatz
|
|
micro <datei> einfacher Editor (Ctrl+S, Ctrl+Q)
|
|
|
|
BILDER (~/bin)
|
|
────────────────────────────────────────────────────────────────
|
|
h2j / heic2jpg HEIC → JPG konvertieren
|
|
heic2jpg_resize + verkleinern
|
|
heic2jpg_delete + HEIC loeschen
|
|
heic2jpg_resize_delete + beides
|
|
jpg_resize nur JPG verkleinern
|
|
|
|
SYSTEM & KONFIG
|
|
────────────────────────────────────────────────────────────────
|
|
fetch fastfetch (Systeminfo)
|
|
cb Clipboard bereinigen (2 Leerzeichen weg)
|
|
zshconfig ~/.zshrc bearbeiten
|
|
p10kconfig ~/.p10k.zsh bearbeiten
|
|
tldr <befehl> Kurzanleitung mit Beispielen
|
|
|
|
MACBOOK-SETUP (curl | bash)
|
|
────────────────────────────────────────────────────────────────
|
|
setup-base.sh <13|16> Basis-Setup (als root)
|
|
setup-desktop.sh Desktop + Apps (als user)
|
|
|
|
SPASS
|
|
────────────────────────────────────────────────────────────────
|
|
cmatrix Matrix-Regen (q = quit)
|
|
asciiquarium Aquarium im Terminal (q = quit)
|
|
fortune | cowsay zufaelliger Spruch mit Kuh
|
|
|
|
TOOLS
|
|
}
|
|
|
|
# Terminal-Screensaver: zufaellig cmatrix oder asciiquarium nach 5 Min Idle
|
|
TMOUT=300
|
|
TRAPALRM() {
|
|
local screensavers=()
|
|
command -v cmatrix &>/dev/null && screensavers+=("cmatrix -sab")
|
|
command -v asciiquarium &>/dev/null && screensavers+=("asciiquarium")
|
|
(( ${#screensavers[@]} )) && eval "${screensavers[$((RANDOM % ${#screensavers[@]} + 1))]}"
|
|
}
|
|
|
|
# Begruessung: zufaellig Systemstatus, Spruch oder Witz
|
|
if [[ -o interactive ]] && command -v cowsay &>/dev/null; then
|
|
_greet() {
|
|
local all_cows=(default tux sheep elephant dragon gnu koala)
|
|
local cow_files=()
|
|
local cowpath=$(cowsay -l 2>/dev/null | tail -n +2 | tr ' ' '\n')
|
|
for c in "${all_cows[@]}"; do
|
|
echo "$cowpath" | grep -qx "$c" && cow_files+=("$c")
|
|
done
|
|
(( ${#cow_files[@]} == 0 )) && cow_files=(default)
|
|
local cow="${cow_files[$((RANDOM % ${#cow_files[@]} + 1))]}"
|
|
case $((RANDOM % 3)) in
|
|
0) # Systemstatus
|
|
local host load
|
|
host=$(hostname -s)
|
|
load=$(uptime | sed 's/.*average[s]*: *\([^ ]*\).*/\1/')
|
|
echo "$host | load $load" | cowsay -f "$cow"
|
|
;;
|
|
1) # Datum-Spruch
|
|
local day=$(date +%u) msg
|
|
case $day in
|
|
1) msg="Montag... Kaffee ist Pflicht!" ;;
|
|
2) msg="Dienstag - immerhin kein Montag mehr." ;;
|
|
3) msg="Mittwoch - Bergfest!" ;;
|
|
4) msg="Donnerstag - morgen ist fast Wochenende!" ;;
|
|
5) msg="Freitag! Die Woche gehoert dir." ;;
|
|
6) msg="Samstag - Zeit fuer Projekte!" ;;
|
|
7) msg="Sonntag - entspann dich mal." ;;
|
|
esac
|
|
echo "$msg ($(date '+%d.%m.%Y, %H:%M'))" | cowsay -f "$cow"
|
|
;;
|
|
2) # Witz/Spruch via fortune
|
|
if command -v fortune &>/dev/null; then
|
|
fortune -s 2>/dev/null | cowsay -f "$cow"
|
|
else
|
|
echo "Keine Witze installiert. Sad." | cowsay -f "$cow"
|
|
fi
|
|
;;
|
|
esac
|
|
}
|
|
_greet
|
|
unfunction _greet
|
|
fi
|