Konfiguracja Bash + Starship (Style: Lean/Zsh)
Dokumentacja kroków podjętych w celu transformacji Basha w nowoczesną powłokę o wyglądzie i funkcjonalności Zsh/Oh My Zsh.
1. Instalacja wymaganych narzędzi
Wybierz komendę odpowiednią dla Twojego systemu:
Fedora / RHEL / CentOS
sudo dnf install starship fzf zoxide
Debian / Ubuntu / Mint
# Uwaga: starship może wymagać dodania repozytorium lub użycia metody uniwersalnej
sudo apt update && sudo apt install starship fzf zoxide
Arch Linux / Manjaro / EndeavourOS
sudo pacman -S starship fzf zoxide
macOS (Homebrew)
brew install starship fzf zoxide
Metoda uniwersalna (jeśli brak w repozytorium)
# Instalacja Starship
curl -sS https://starship.rs/install.sh | sh
# fzf i zoxide zazwyczaj są w standardowych repozytoriach wszystkich dystrybucji
2. Konfiguracja Starship (~/.config/starship.toml)
Plik ten odpowiada za wygląd “Lean” inspirowany Powerlevel10k.
"$schema" = 'https://starship.rs/config-schema.json'
# Układ linii
format = """
$os
$directory
$git_branch
$git_status
$fill
$python
$nodejs
$rust
$golang
$php
$java
$c
$status
$cmd_duration
$time
$line_break
$character"""
# Ustawienia ogólne
add_newline = false
[fill]
symbol = " "
[character]
success_symbol = "[❯](bold green)"
error_symbol = "[❯](bold red)"
[os]
disabled = false
style = "bold white"
[os.symbols]
Fedora = " "
Ubuntu = " "
Linux = " "
[directory]
style = "fg:31 bold"
read_only = " "
truncate_to_repo = false
truncation_length = 3
truncation_symbol = "…/"
[git_branch]
symbol = " "
style = "fg:76"
format = "on [$symbol$branch]($style) "
[git_status]
style = "fg:76"
format = "([$all_status$ahead_behind]($style))"
conflicted = "="
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
up_to_date = ""
untracked = "?${count}"
stashed = "*${count}"
modified = "!${count}"
staged = "+${count}"
renamed = "»${count}"
deleted = "✘${count}"
[status]
disabled = false
format = "[$symbol$status]($style) "
symbol = "✘"
success_symbol = "✔"
style = "fg:160"
[cmd_duration]
min_time = 3000
format = "took [$duration]($style) "
style = "fg:101"
[time]
disabled = false
time_format = "%H:%M:%S"
format = "at [$time]($style)"
style = "fg:66"
3. Konfiguracja Basha (~/.bashrc)
Dodaj te wpisy, aby aktywować funkcjonalności:
# --- Ulepszone autouzupełnianie (Menu Completion) ---
bind 'set completion-ignore-case on'
bind 'set show-all-if-ambiguous on'
bind 'set mark-directories on'
bind 'set colored-stats on'
bind 'set menu-complete-display-prefix on'
bind 'TAB: menu-complete'
bind '"\e[Z": menu-complete-backward'
# --- Szukanie w historii strzałkami ---
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\eOA": history-search-backward'
bind '"\eOB": history-search-forward'
# --- fzf History Search (Ctrl+R) ---
hs() {
local selected_command=$(history | perl -ne 's/^\s*\d+\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s+//; print' | fzf --prompt="[history]: " --height=40% --layout=reverse --border --query="$*")
if [ -n "$selected_command" ]; then
history -s "$selected_command"
eval "$selected_command"
fi
}
bind -x '"\C-r": hs'
# --- Ustawienia historii ---
export HISTSIZE=10000
export HISTFILESIZE=20000
export HISTCONTROL=ignoreboth:erasedups
export HISTTIMEFORMAT="%F %T "
export PROMPT_COMMAND="history -a; history -n; $PROMPT_COMMAND"
# --- Zoxide (Smart cd) ---
if command -v zoxide &> /dev/null; then
eval "$(zoxide init bash)"
alias cd='z'
fi
# --- Funkcje i Aliasy OMZ Style ---
alias l='ls -lah'
alias ..='cd ..'
alias gst='git status'
extract() {
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "'$1' cannot be extracted" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
mkcd() {
mkdir -p "$1" && cd "$1"
}
# --- Inicjalizacja Starship ---
eval "$(starship init bash)"
4. Aktywacja zmian
source ~/.bashrc
5. Ściąga (Cheatsheet) i skróty klawiszowe
Po zastosowaniu powyższej konfiguracji, Twój terminal zyskał następujące supermoce:
Skróty klawiszowe (Key Bindings)
| Skrót | Działanie |
|---|---|
TAB |
Otwiera menu autouzupełniania (można nawigować TABem) |
Shift + TAB |
Cofa wybór w menu autouzupełniania |
Strzałka w górę |
Przeszukuje historię (tylko komendy zaczynające się od wpisanych znaków) |
Strzałka w dół |
Przeszukuje historię w przód |
Ctrl + R |
Wywołuje fzf – interaktywną, rozmytą wyszukiwarkę historii |
Przydatne aliasy i funkcje
| Komenda | Działanie |
|---|---|
l |
Listowanie plików w formacie ls -lah (pokaż wszystko) |
.. |
Szybkie wyjście o jeden katalog wyżej |
gst |
Skrót do git status |
cd <fraza> |
Inteligentna nawigacja (zoxide) – np. cd desk przeniesie Cię do ~/Desktop |
mkcd <nazwa> |
Tworzy katalog i od razu do niego wchodzi |
extract <plik> |
Automatycznie rozpoznaje i rozpakowuje archiwum (zip, tar.gz, 7z) |
Wskazówka: Aby w pełni cieszyć się ikonami, upewnij się, że Twój emulator terminala używa czcionki typu Nerd Font (np. JetBrainsMono Nerd Font).