Last active
August 6, 2025 10:21
-
-
Save ceroberoz/094ec27b31ceedad89971ed8b6bdf28d to your computer and use it in GitHub Desktop.
Opinionated fish shell config (+ starship.rs) for daily sysadmin and light python / shell scripting for Apple M1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ───────────────────────────────────── | |
# Exit early if not interactive | |
# ───────────────────────────────────── | |
if not status is-interactive | |
return | |
end | |
# ───────────────────────────────────── | |
# Homebrew (Apple Silicon) | |
# ───────────────────────────────────── | |
set -gx HOMEBREW_PREFIX /opt/homebrew | |
set -gx HOMEBREW_NO_ANALYTICS 1 # Privacy: disable reporting | |
# Add to PATH only if not already present | |
for dir in $HOMEBREW_PREFIX/bin $HOMEBREW_PREFIX/sbin | |
if not contains $dir $PATH | |
set -gx PATH $dir $PATH | |
end | |
end | |
# Optional: man pages | |
if not contains $HOMEBREW_PREFIX/share/man $MANPATH | |
set -gx MANPATH $HOMEBREW_PREFIX/share/man $MANPATH | |
end | |
# ───────────────────────────────────── | |
# Environment Variables | |
# ───────────────────────────────────── | |
set -gx XDG_DATA_HOME ~/.local/share | |
set -gx XDG_CONFIG_HOME ~/.config | |
set -gx EDITOR nvim | |
set -gx GIT_EDITOR nvim | |
set -gx PAGER less | |
set -gx LESS '-F -g -i -M -R -S -w -X -z-4' | |
# Python: prefer bundled tools | |
set -gx PYTHONUNBUFFERED 1 | |
# Set a smart PYTHONBREAKPOINT (ipdb with pdb fallback) | |
function _set_python_breakpoint | |
if command -v ipdb >/dev/null | |
set -gx PYTHONBREAKPOINT ipdb.set_trace | |
else | |
set -gx PYTHONBREAKPOINT pdb.set_trace | |
end | |
end | |
_set_python_breakpoint | |
functions -e _set_python_breakpoint | |
# ───────────────────────────────────── | |
# Shell UX & Behavior | |
# ───────────────────────────────────── | |
set -g fish_cursor_default beam # I-beam cursor | |
set -g fish_greeting '' # No welcome spam | |
set -g history_merge_dups yes # Merge history | |
set -g history_duplicates delete # No duplicates | |
set -g fish_pager_color_completion normal # Subtle completions | |
set -g fish_pager_color_description cyan # Nice help text | |
set -g fish_color_error red # Standout errors | |
# Autosuggestions: show what's likely | |
set -g fish_autosuggestion_enabled yes | |
set -g fish_autosuggestion_strategy [commandline -C] | |
# Highlighting: enable if plugin is installed | |
# (install: fisher install jorgebucaran/fish-syntax-highlighting) | |
# ───────────────────────────────────── | |
# Prompt: Starship 🚀 | |
# ───────────────────────────────────── | |
# Opinion: Let starship handle everything — clean, fast, modular | |
if status --is-interactive | |
starship init fish | source | |
end | |
# ───────────────────────────────────── | |
# Abbreviations (Fish > Aliases) | |
# ───────────────────────────────────── | |
# Filesystem | |
abbr -a ll 'ls -laFh --color=auto' # Full list | |
abbr -a la 'ls -A --color=auto' # Hidden files | |
abbr -a l 'ls -CFh --color=auto' # Compact | |
abbr -a md 'mkdir -p' | |
abbr -a path 'echo $PATH | tr ":" "\n"' | |
# Git | |
abbr -a gs 'git status' | |
abbr -a gd 'git diff' | |
abbr -a ga 'git add' | |
abbr -a gc 'git commit' | |
abbr -a gca 'git commit -a' | |
abbr -a gp 'git push' | |
abbr -a gpl 'git pull' | |
abbr -a gco 'git checkout' | |
abbr -a gb 'git branch' | |
abbr -a gl 'git log --oneline --graph' | |
# Navigation | |
abbr -a .. 'cd ..' | |
abbr -a ... 'cd ../..' | |
abbr -a .... 'cd ../../..' | |
# Tools | |
abbr -a v 'nvim' | |
abbr -a d 'docker' | |
abbr -a dc 'docker-compose' | |
abbr -a k 'kubectl' | |
abbr -a mux 'tmux' | |
abbr -a web 'python3 -m http.server 8000' | |
# Networking | |
abbr -a ip 'ipconfig getifaddr en0 || ip a' | |
abbr -a myip 'curl -s ifconfig.me' | |
abbr -a ports 'sudo lsof -i -P -n | grep LISTEN' | |
# Process & Sysadmin | |
abbr -a pg 'ps aux | grep -i' | |
abbr -a sudo 'sudo ' | |
abbr -a update 'brew update && brew upgrade' | |
# ───────────────────────────────────── | |
# Python: Auto venv Activation | |
# ───────────────────────────────────── | |
# Automatically activate .venv when entering directory | |
function _activate_venv --on-variable PWD | |
set venv_dir (pwd)/.venv | |
if test -d $venv_dir | |
if not set -q VIRTUAL_ENV | |
if source $venv_dir/bin/activate.fish 2>/dev/null | |
echo -s "🐍 Activated .venv" | |
else if source $venv_dir/bin/activate 2>/dev/null | |
echo -s "🐍 Activated .venv (sh)" | |
end | |
end | |
else if set -q VIRTUAL_ENV | |
# Optional: auto-deactivate? Not enabled — too aggressive | |
# Let users `deactivate` manually | |
end | |
end | |
# ───────────────────────────────────── | |
# pyenv Support (Optional) | |
# ───────────────────────────────────── | |
# Only if you use pyenv | |
set -gx PYENV_ROOT ~/.pyenv | |
if status is-interactive | |
if command -v pyenv >/dev/null | |
set -gx PATH $PYENV_ROOT/bin $PATH | |
pyenv init - | source | |
end | |
end | |
# ───────────────────────────────────── | |
# Private Config (secrets, keys, etc.) | |
# ───────────────────────────────────── | |
# Example: ~/.config/fish/private.fish | |
# set -gx AWS_PROFILE admin | |
# set -gx DOCKER_HOST ... | |
if test -f ~/.config/fish/private.fish | |
source ~/.config/fish/private.fish | |
end | |
# ───────────────────────────────────── | |
# Optional: Welcome Message | |
# ───────────────────────────────────── | |
# Uncomment if you want a daily reminder | |
# echo "📅 $(date '+%A, %b %d') | 🛠 Sysadmin mode: engaged" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recommended Plugins (Install Once)
Run these one time to enhance your shell: