130 lines
6.4 KiB
Bash
130 lines
6.4 KiB
Bash
#
|
|
# ~/.bashrc — Interactive bash shell configuration
|
|
#
|
|
# This file is sourced for every non-login interactive bash session.
|
|
# Bash is the fallback shell on this system; zsh is the primary interactive
|
|
# shell. This file mirrors a core subset of .zshrc's aliases so the
|
|
# environment is consistent inside TTYs and distrobox containers.
|
|
#
|
|
|
|
# Guard: only run for interactive shells.
|
|
# $- contains the set of active shell option flags; 'i' means interactive.
|
|
# If 'i' is absent, return immediately — this prevents errors when bash is
|
|
# invoked non-interactively (e.g., from scripts or scp file transfers).
|
|
[[ $- != *i* ]] && return
|
|
|
|
# ─── Core aliases ──────────────────────────────────────────────────────────────
|
|
|
|
# Colorize ls and grep output — file types and match highlights stand out visually.
|
|
alias ls='ls --color=auto'
|
|
alias grep='grep --color=auto'
|
|
|
|
# $PS1: minimal prompt showing [user@host workingdir]$
|
|
# This is the bash default; starship replaces it at the bottom of this file.
|
|
# Kept here as a safe fallback if starship fails to initialize.
|
|
PS1='[\u@\h \W]\$ '
|
|
|
|
# Detailed directory listing with ISO timestamps (YYYY-MM-DD HH:MM).
|
|
# ISO format is sortable and unambiguous compared to locale-default date strings.
|
|
alias ll="ls -la --time-style=long-iso"
|
|
alias l="ll" # Short form for everyday use
|
|
|
|
# Quick parent-directory navigation — equivalent to 'cd ..'
|
|
alias ..="cd .."
|
|
|
|
# Editor shortcuts: micro is a terminal text editor with intuitive keybindings
|
|
# (Ctrl+S to save, Ctrl+Q to quit), suitable for quick in-terminal edits.
|
|
alias m="micro"
|
|
alias sm="sudo micro" # Elevated edit for system files owned by root
|
|
|
|
# ─── Git shortcuts ─────────────────────────────────────────────────────────────
|
|
|
|
alias gita="git add ." # Stage all changes in the current working tree
|
|
alias gitc="git commit -m" # Commit with an inline message, e.g.: gitc "fix: typo"
|
|
alias gitp="git push" # Push current branch to its remote tracking branch
|
|
|
|
# curl-based weather lookup — wttr.in returns ANSI-art weather for the terminal.
|
|
# The trailing slash with no city causes wttr.in to auto-detect location via IP.
|
|
alias weather="curl https://wttr.in/"
|
|
|
|
# ─── gitf(): stage → commit → push in a single command ───────────────────────
|
|
# Usage: gitf "commit message"
|
|
# Collapses the three-step add/commit/push workflow for quick, minor commits.
|
|
# The $1 guard prevents an empty commit message (which git would reject anyway,
|
|
# but this gives a cleaner user-facing error).
|
|
function gitf() {
|
|
|
|
if [ -z $1 ]; then
|
|
echo "no commit message, doing nothing"
|
|
else
|
|
echo "directly commiting with message \"$1\""
|
|
git add .
|
|
git commit -m $1
|
|
git push
|
|
fi
|
|
}
|
|
|
|
# ─── Kitty terminal integration ────────────────────────────────────────────────
|
|
|
|
# icat: display images inline in the terminal using Kitty's icat kitten.
|
|
# Only works inside a Kitty terminal; other terminals will display an error.
|
|
alias icat="kitten icat"
|
|
|
|
# Two ways to clear the screen — cls is familiar muscle memory from Windows cmd.
|
|
alias cls="clear"
|
|
|
|
# Kitten SSH: wraps ssh with Kitty's ssh kitten so the remote shell inherits
|
|
# correct terminfo entries and Kitty protocol extensions (OSC 52 clipboard,
|
|
# proper backspace, 24-bit color, etc.) without manual TERM setup on the server.
|
|
alias ssh="kitten ssh"
|
|
alias ssk="kitten ssh" # Typo-resilient duplicate
|
|
|
|
# ─── Hardware / misc ───────────────────────────────────────────────────────────
|
|
|
|
# tio: terminal I/O program for serial port communication (embedded dev, etc.).
|
|
# '-a latest' attaches to the most recently enumerated serial device.
|
|
# sudo is required because /dev/ttyUSB* and /dev/ttyACM* are typically owned
|
|
# by the 'uucp' or 'dialout' group and not accessible as a regular user by default.
|
|
alias serial="sudo tio -a latest"
|
|
|
|
# t: alias for 'wd' (warp directory) — jump to named directory bookmarks.
|
|
# Bookmarks are set with: wd add <name> and jumped to with: t <name>
|
|
alias t="wd"
|
|
|
|
# Filtered listing — pipe a long-format listing through grep for fast file search.
|
|
alias lgrep="l | grep"
|
|
alias lg="lgrep" # Short form
|
|
|
|
# ─── y(): yazi file manager with shell directory-change on exit ─────────────────
|
|
# Yazi is a terminal file manager. Without this wrapper, any directory you
|
|
# navigate to inside yazi is lost when it exits (it ran in a subshell).
|
|
# This wrapper passes --cwd-file to yazi; yazi writes its final CWD there,
|
|
# and the wrapper reads it to cd the parent shell into that directory.
|
|
function y() {
|
|
local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd # temp file to capture yazi's last dir
|
|
yazi "$@" --cwd-file="$tmp" # run yazi; it writes final dir to $tmp
|
|
if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
|
builtin cd -- "$cwd" # apply the directory change to this shell
|
|
fi
|
|
rm -f -- "$tmp" # clean up the temp file
|
|
}
|
|
|
|
|
|
|
|
# ─── Prompt & startup ──────────────────────────────────────────────────────────
|
|
|
|
# Initialize starship for bash. Starship is a cross-shell prompt engine configured
|
|
# in ~/Dotfiles/starship.toml. It replaces the plain PS1 above with a rich,
|
|
# segment-based prompt showing user, path, git branch/status, language versions,
|
|
# and the current time — all styled with the CyberQueer color palette.
|
|
eval "$(starship init bash)"
|
|
|
|
# Display system info on shell start using fastfetch with the custom ASCII logo.
|
|
# Colors are forced to red to match the CyberQueer theme branding.
|
|
fastfetch --logo-color-1 red --logo-color-2 red --color red -l ~/Dotfiles/pin.txt
|
|
|
|
# Load the Rust/Cargo environment — primarily adds ~/.cargo/bin to PATH so that
|
|
# binaries installed via `cargo install` (e.g., ripgrep, bat, starship itself)
|
|
# are immediately accessible in this session.
|
|
. "$HOME/.cargo/env"
|