#!/bin/bash # Set up some ls settings. if [[ "$OSTYPE" == "darwin"* ]]; then alias ls='ls -ph' else alias ls='ls -p --color -h --group-directories-first --hide=__pycache__' fi # Open files easily with `o` if [[ "$OSTYPE" == "darwin"* ]]; then alias o='open' else alias o='xdg-open' fi # Aliases for typing git commands really quickly. # shellcheck disable=SC2139 alias gl='git log --first-parent' alias gd_=$'git diff -M -D' alias gd='gd_ --cached' alias ga='git add -A' alias gbs='git branch-select' # Make ag do nothing at all, to prevent running silversearcher alias ag='true' alias gb='git branch' alias justdoit='git add -A :/ && gd' alias gf='git fetch --all --prune' alias gpf='git push --force-with-lease' alias amend='git commit --amend --no-edit' alias st='git status' alias gco='git checkout' alias gls='git ls-tree -r --name-only' # Creating quick ZIPs for git repos. # shellcheck disable=SC2139 alias git-zip='git archive --format zip "$(git rev-parse HEAD)" --output' alias gsquash='git merge --ff --squash' # Show an overview of stuff in the git log, with just the right amount of information alias git-overview='git log --decorate --graph --first-parent --branches --oneline' # shellcheck disable=SC2139 alias nopyc=$'find `git rev-parse --show-toplevel` -name \'*.pyc\' -not -path \'*/site-packages/*\' -delete' # shellcheck disable=SC2139 alias tracking=$'git for-each-ref --format=\'%(upstream:short)\' $(git symbolic-ref -q HEAD)' # Find branches which have been merge to the dev branch. # shellcheck disable=SC2139 alias merged-to-dev=$'git branch --merged dev | cut -c 3- | grep -P --invert-match \'^(?:master|dev|release/.+)$\'' # Add aliases for printing GitHub URLs for things. # shellcheck disable=SC2139 alias git-current-remote-name=$'git rev-parse --abbrev-ref --symbolic-full-name @{u} | sed \'s:/.*$::\'' alias github-url=$'echo "https://github.com/$(git config --get remote.$(git-current-remote-name).url)" | sed \'s/\.git$//\' | sed \'s/git@github.com://\'' # shellcheck disable=SC2139 alias github.amrom.workers.devmit-url=$'echo "$(github-url)/commit/$(git rev-parse HEAD)"' # shellcheck disable=SC2139 alias github-branch-url=$'echo "$(github-url)/tree/$(git rev-parse --abbrev-ref HEAD)"' alias github-actions-url=$'echo "$(github-url)/actions"' # Make GVim open files in a tab instead of a window. alias gvim='~/script/unix/gvim' # Add aliases for the OpenSSL commands I can never remember. alias check-cert='openssl x509 -text -noout -in' # Make `..` do `cd ..` alias ..='cd ..' # Get information about the GPU! alias gpuinfo='cat $(find /proc/driver/ -type f -name information) /proc/driver/*/version' alias ve='source ~/script/scripts-for-aliases/virtualenv-script' # shellcheck disable=SC2142 alias env-mismatches='grep -nH "[A-Z_]=" *.y*ml | awk -F= '\''{ split($1, a, ":"); file=a[1]; ln=a[2]; lhs=a[3]; gsub(/^ *- */, "", lhs); gsub(/^ +| +$/, "", lhs); rest=substr($0, index($0, a[3])); if (match(rest, /\$\{[A-Z_][A-Z0-9_]*/)) { var=substr(rest, RSTART+2, RLENGTH-2); if (lhs != var) print file ":" ln ": " rest } }'\''' # Auto add missing requirements with pipreqs alias auto-uv-add='pipreqs --print src/ 2>/dev/null | xargs -n1 uv add' # aliases specific to Mac OSX. if [[ "$OSTYPE" =~ ^darwin ]]; then # Automatically use the MacVim version of Vim. if [ -f /Applications/MacVim.app/Contents/MacOS/Vim ]; then alias vim=/Applications/MacVim.app/Contents/MacOS/Vim fi fi # Add a claude-plans alias for showing Claude Code plans. if [[ "$OSTYPE" =~ ^darwin ]]; then alias claude-plans='command gls -lth --color=auto --hyperlink=auto ~/.claude/plans' else alias claude-plans='/bin/ls -lth --color=auto --hyperlink=auto ~/.claude/plans' fi