init
This commit is contained in:
125
bash/.bashrc
Normal file
125
bash/.bashrc
Normal file
@@ -0,0 +1,125 @@
|
||||
# ~/.bashrc
|
||||
# Loaded for interactive non-login shells.
|
||||
# Keep this file readable. Each section explains what it does.
|
||||
|
||||
# If not running interactively, do nothing.
|
||||
# This prevents issues when bash is invoked by scp or scripts.
|
||||
case $- in
|
||||
*i*) ;;
|
||||
*) return ;;
|
||||
esac
|
||||
|
||||
# ============================================================
|
||||
# HISTORY
|
||||
# ============================================================
|
||||
HISTSIZE=10000
|
||||
HISTFILESIZE=20000
|
||||
HISTCONTROL=ignoredups:erasedups # don't store duplicate lines
|
||||
shopt -s histappend # append to history, don't overwrite it
|
||||
|
||||
# ============================================================
|
||||
# PROMPT
|
||||
# ============================================================
|
||||
# \u = username, \h = hostname, \w = current directory
|
||||
# \e[COLORm = color code, \e[0m = reset color
|
||||
# 32 = green, 34 = blue, 33 = yellow
|
||||
__git_branch() {
|
||||
local branch
|
||||
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
|
||||
[ -n "$branch" ] && echo " ($branch)"
|
||||
}
|
||||
|
||||
PS1='\e[32m\u@\h\e[0m:\e[34m\w\e[33m$(__git_branch)\e[0m\$ '
|
||||
|
||||
# ============================================================
|
||||
# COMPLETION
|
||||
# ============================================================
|
||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# EDITOR
|
||||
# ============================================================
|
||||
export EDITOR=nvim
|
||||
export VISUAL=nvim
|
||||
|
||||
# ============================================================
|
||||
# PATH
|
||||
# ============================================================
|
||||
# Add your personal scripts to PATH
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# mise runtime manager — activates shims for node, dotnet, etc.
|
||||
# See: ~/.config/mise/config.toml
|
||||
if command -v mise &>/dev/null; then
|
||||
eval "$(mise activate bash)"
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# ALIASES
|
||||
# ============================================================
|
||||
|
||||
# Navigation
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias ll='ls -lah --color=auto'
|
||||
alias la='ls -A --color=auto'
|
||||
alias l='ls -CF --color=auto'
|
||||
|
||||
# Safety: ask before overwriting
|
||||
alias rm='rm -i'
|
||||
alias cp='cp -i'
|
||||
alias mv='mv -i'
|
||||
|
||||
# Quick edit and reload this file
|
||||
alias bashrc='${EDITOR} ~/.bashrc && source ~/.bashrc'
|
||||
|
||||
# Git shortcuts (plain, no magic)
|
||||
alias gs='git status'
|
||||
alias ga='git add'
|
||||
alias gc='git commit'
|
||||
alias gp='git push'
|
||||
alias gl='git log --oneline --graph --decorate -20'
|
||||
|
||||
# Notes shortcuts
|
||||
# Opens inbox for quick capture
|
||||
alias inbox='${EDITOR} ~/notes/inbox.md'
|
||||
|
||||
# Opens or creates today's daily note from template
|
||||
today() {
|
||||
local file=~/notes/daily/$(date +%Y-%m-%d).md
|
||||
mkdir -p ~/notes/daily
|
||||
if [ ! -f "$file" ]; then
|
||||
sed "s/YYYY-MM-DD/$(date +%Y-%m-%d)/g" \
|
||||
~/notes/templates/daily.md > "$file"
|
||||
fi
|
||||
${EDITOR} "$file"
|
||||
}
|
||||
|
||||
# Opens or creates this week's weekly note from template
|
||||
thisweek() {
|
||||
local week=~/notes/weekly/$(date +%Y-W%V).md
|
||||
mkdir -p ~/notes/weekly
|
||||
if [ ! -f "$week" ]; then
|
||||
sed "s/YYYY-WNN/$(date +%Y-W%V)/g" \
|
||||
~/notes/templates/weekly.md > "$week"
|
||||
fi
|
||||
${EDITOR} "$week"
|
||||
}
|
||||
|
||||
# Find all open tasks across all notes
|
||||
alias tasks='grep -r "\- \[ \]" ~/notes/ --include="*.md"'
|
||||
|
||||
# Open decisions log
|
||||
alias decisions='${EDITOR} ~/notes/decisions.md'
|
||||
|
||||
# ============================================================
|
||||
# FUNCTIONS
|
||||
# ============================================================
|
||||
# Only add functions you can explain line by line.
|
||||
|
||||
# mkcd: create a directory and immediately enter it
|
||||
mkcd() {
|
||||
mkdir -p "$1" && cd "$1"
|
||||
}
|
||||
Reference in New Issue
Block a user