154 lines
2.7 KiB
Markdown
154 lines
2.7 KiB
Markdown
---
|
||
publish: true
|
||
permalink: /os/shell
|
||
title: Shell
|
||
created: 2026-01-29T16:18:01.019-07:00
|
||
modified: 2026-02-05T12:18:10.588-07:00
|
||
tags:
|
||
- shell
|
||
- terminal
|
||
- bash
|
||
cssclasses: ""
|
||
---
|
||
|
||
Shell configuration with Bash, Starship prompt, and Atuin history.
|
||
|
||
## Starship Prompt
|
||
|
||
Starship is a fast, customizable prompt that works with any shell.
|
||
|
||
### Installation
|
||
|
||
```bash
|
||
curl -sS https://starship.rs/install.sh | sh
|
||
```
|
||
|
||
Or via pacman:
|
||
```bash
|
||
sudo pacman -S starship
|
||
```
|
||
|
||
### Bash Integration
|
||
|
||
Add to `~/.bashrc`:
|
||
```bash
|
||
eval "$(starship init bash)"
|
||
```
|
||
|
||
### Configuration
|
||
|
||
Config location: `~/.config/starship.toml`
|
||
|
||
```toml
|
||
# Minimal prompt
|
||
format = """
|
||
$directory\
|
||
$git_branch\
|
||
$git_status\
|
||
$character"""
|
||
|
||
[directory]
|
||
truncation_length = 3
|
||
truncate_to_repo = true
|
||
|
||
[git_branch]
|
||
symbol = " "
|
||
|
||
[git_status]
|
||
format = '([$all_status$ahead_behind]($style) )'
|
||
|
||
[character]
|
||
success_symbol = "[❯](green)"
|
||
error_symbol = "[❯](red)"
|
||
```
|
||
|
||
## Atuin (Shell History)
|
||
|
||
See [[10-19 LIFE/13 TECH SETUP/13.11 APPS/atuin]] for full setup. Quick integration:
|
||
|
||
```bash
|
||
# Install
|
||
curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
|
||
|
||
# Add to ~/.bashrc
|
||
. "$HOME/.atuin/bin/env"
|
||
[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh
|
||
eval "$(atuin init bash)"
|
||
```
|
||
|
||
## My .bashrc Structure
|
||
|
||
I keep my bashrc clean by sourcing external files:
|
||
|
||
```bash
|
||
# ~/.bashrc
|
||
|
||
# If not running interactively, don't do anything
|
||
[[ $- != *i* ]] && return
|
||
|
||
# Basic aliases
|
||
alias ls='ls --color=auto'
|
||
alias grep='grep --color=auto'
|
||
|
||
# PATH
|
||
export PATH="/home/phil/.local/bin:$PATH"
|
||
export PATH="$HOME/.npm-global/bin:$PATH"
|
||
export PATH="$PATH:$HOME/go/bin"
|
||
|
||
# Starship
|
||
eval "$(starship init bash)"
|
||
|
||
# Atuin
|
||
. "$HOME/.atuin/bin/env"
|
||
[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh
|
||
eval "$(atuin init bash)"
|
||
|
||
# Custom config (aliases, functions)
|
||
source ~/.config/dotfiles/aliases
|
||
source ~/.config/dotfiles/functions
|
||
|
||
# Completions
|
||
source <(openclaw completion --shell bash)
|
||
```
|
||
|
||
### Modular Config
|
||
|
||
Keep aliases and functions in separate files:
|
||
|
||
```
|
||
~/.config/dotfiles/
|
||
├── aliases # alias definitions
|
||
└── functions # shell functions
|
||
```
|
||
|
||
This keeps `.bashrc` clean and makes it easy to version control customizations separately.
|
||
|
||
## Useful Tools
|
||
|
||
```bash
|
||
sudo pacman -S \
|
||
fzf # Fuzzy finder
|
||
bat # Better cat
|
||
eza # Better ls
|
||
ripgrep # Better grep
|
||
fd # Better find
|
||
```
|
||
|
||
### fzf Integration
|
||
|
||
```bash
|
||
# Add to ~/.bashrc
|
||
source /usr/share/fzf/key-bindings.bash
|
||
source /usr/share/fzf/completion.bash
|
||
```
|
||
|
||
Keybindings:
|
||
- `Ctrl+R` — Search history (or use Atuin)
|
||
- `Ctrl+T` — Search files
|
||
- `Alt+C` — cd into directory
|
||
|
||
## Resources
|
||
|
||
- Starship: https://starship.rs/
|
||
- Atuin: https://atuin.sh/
|