2026-06-11 18:28:00 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# Aliases used in all kinds of shells
|
|
|
|
|
|
|
|
|
|
|
2026-08-03 02:02:37 +02:00
|
|
|
# Make this file work standalone in non-interactive `bash` (e.g., ":!cmd" in `vim`)
|
|
|
|
|
|
|
|
|
|
if [ -n "${BASH_VERSION:-}" ]; then
|
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! command -v _command_exists >/dev/null 2>&1; then
|
|
|
|
|
# This utility is supposed to be defined only in ~/.profile but copied here
|
|
|
|
|
# to make `$BASH_ENV` work in `vim`, which sources this file only
|
|
|
|
|
_command_exists() {
|
|
|
|
|
command -v "$1" 1>/dev/null 2>&1
|
|
|
|
|
}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-11 18:28:00 +02:00
|
|
|
# Manage the bare `git` repository in ~/ holding the dotfiles
|
|
|
|
|
alias dotfiles='git --git-dir=$DOTFILES_DIR --work-tree=$HOME'
|
|
|
|
|
|
|
|
|
|
|
2026-06-11 18:28:02 +02:00
|
|
|
|
|
|
|
|
forget() { # the current history and restore $HISTFILE from disk
|
|
|
|
|
if [ -n "$BASH_VERSION" ]; then
|
|
|
|
|
history -c
|
|
|
|
|
history -r
|
2026-06-11 18:28:02 +02:00
|
|
|
elif [ -n "$ZSH_VERSION" ]; then
|
|
|
|
|
local _histsize=$HISTSIZE
|
|
|
|
|
HISTSIZE=0 # because shrinking the list to 0 discards all entries
|
|
|
|
|
HISTSIZE=$_histsize
|
|
|
|
|
fc -R "$HISTFILE"
|
2026-06-11 18:28:02 +02:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-11 18:28:02 +02:00
|
|
|
if [ -n "$ZSH_VERSION" ]; then
|
|
|
|
|
alias forget=' forget' # Leading space => The invocation itself is forgotten
|
|
|
|
|
fi
|
|
|
|
|
|
2026-06-11 18:28:02 +02:00
|
|
|
|
|
|
|
|
|
2026-06-11 18:32:27 +02:00
|
|
|
if _command_exists git; then
|
|
|
|
|
|
|
|
|
|
# Check if a "main" branch exists in place of a "master" branch
|
|
|
|
|
git_main_branch() {
|
|
|
|
|
if [ -n "$(git branch --list main)" ]; then
|
|
|
|
|
echo "main"
|
|
|
|
|
else
|
|
|
|
|
echo "master"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alias g='git'
|
|
|
|
|
|
|
|
|
|
alias ga='git add'
|
|
|
|
|
alias gap='git add --patch'
|
|
|
|
|
|
|
|
|
|
alias gbr='git branch'
|
|
|
|
|
alias gbra='git branch --all'
|
|
|
|
|
alias gbrd='git branch --delete'
|
|
|
|
|
alias gbrdd='git branch --delete --force'
|
|
|
|
|
alias gbrm='git branch --move'
|
|
|
|
|
|
|
|
|
|
alias gci='git commit'
|
|
|
|
|
alias gcim='git commit --message'
|
|
|
|
|
|
|
|
|
|
alias gcl='git clone'
|
|
|
|
|
|
|
|
|
|
alias gco='git checkout'
|
|
|
|
|
alias gcob='git checkout -b'
|
|
|
|
|
alias gcod='git checkout develop'
|
|
|
|
|
alias gcom='git checkout $(git_main_branch)'
|
|
|
|
|
|
|
|
|
|
alias gcp='git cherry-pick'
|
|
|
|
|
|
|
|
|
|
alias gdf='git diff-minimal'
|
|
|
|
|
alias gdlc='git diff-last-commit'
|
|
|
|
|
alias gds='git diff-staged'
|
|
|
|
|
|
|
|
|
|
alias gfe='git fetch'
|
|
|
|
|
|
|
|
|
|
alias ghi='git history'
|
|
|
|
|
alias ghia='git history --all'
|
|
|
|
|
alias ghif='git history-file'
|
|
|
|
|
alias ghifd='git history-file-diff'
|
|
|
|
|
alias ghip='git history-path'
|
|
|
|
|
alias ghipd='git history-path-diff'
|
|
|
|
|
|
|
|
|
|
alias glc='git last-commit'
|
|
|
|
|
|
|
|
|
|
alias glg='git log'
|
|
|
|
|
alias glga='git log --all'
|
|
|
|
|
|
|
|
|
|
alias gme='git merge'
|
|
|
|
|
alias gmea='git merge --abort'
|
|
|
|
|
alias gmec='git merge --continue'
|
|
|
|
|
alias gmeff='git merge --ff-only'
|
|
|
|
|
alias gmenoff='git merge --no-ff'
|
|
|
|
|
|
|
|
|
|
alias gol='git oneline'
|
|
|
|
|
alias gola='git oneline --all'
|
|
|
|
|
|
|
|
|
|
alias gpl='git pull'
|
|
|
|
|
alias gplrb='git pull --rebase'
|
2026-06-11 18:28:02 +02:00
|
|
|
|
2026-06-11 18:32:27 +02:00
|
|
|
alias gps='git push'
|
|
|
|
|
alias gpsf='git push --force'
|
|
|
|
|
|
|
|
|
|
alias grb='git rebase --committer-date-is-author-date'
|
|
|
|
|
alias grba='git rebase --abort'
|
|
|
|
|
alias grbc='git rebase --continue'
|
|
|
|
|
alias grbi='git rebase --interactive'
|
|
|
|
|
alias grbq='git rebase --quit'
|
|
|
|
|
alias grbs='git rebase --skip'
|
|
|
|
|
|
|
|
|
|
alias grepc='git grep-code'
|
|
|
|
|
alias grepcim='git grep-commit-msg'
|
|
|
|
|
alias grepd='git grep-diff'
|
|
|
|
|
alias grepdl='git grep-diff-list'
|
|
|
|
|
alias grepp='git grep-pickaxe'
|
|
|
|
|
alias grept='git grep-text'
|
|
|
|
|
|
|
|
|
|
alias grl='git reflog'
|
|
|
|
|
|
|
|
|
|
alias grm='git rm'
|
|
|
|
|
|
|
|
|
|
alias grs='git reset'
|
|
|
|
|
|
|
|
|
|
alias grv='git revert'
|
|
|
|
|
|
|
|
|
|
alias gs='git status'
|
|
|
|
|
alias gss='git status --short'
|
|
|
|
|
|
|
|
|
|
alias gsh='git show'
|
|
|
|
|
|
|
|
|
|
alias gst='git stash'
|
|
|
|
|
alias gsta='git stash push --include-untracked'
|
|
|
|
|
alias gstam='git stash push --include-untracked --message'
|
|
|
|
|
alias gstapp='git stash apply'
|
|
|
|
|
alias gstl='git stash list'
|
|
|
|
|
alias gstp='git stash pop'
|
|
|
|
|
alias gstsh='git stash show'
|
|
|
|
|
|
|
|
|
|
alias gsu='git summary'
|
|
|
|
|
alias gsua='git summary --all'
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alias grep='grep --exclude-dir=.git'
|
2026-08-03 04:00:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Make working with Python more convenient
|
|
|
|
|
|
|
|
|
|
alias py='python3'
|
|
|
|
|
|
|
|
|
|
ipy() {
|
|
|
|
|
if command -v ipython >/dev/null 2>&1; then
|
|
|
|
|
ipython "$@"
|
|
|
|
|
elif command -v ipython3 >/dev/null 2>&1; then
|
|
|
|
|
ipython3 "$@"
|
|
|
|
|
else
|
|
|
|
|
echo "ipython not installed" >&2
|
|
|
|
|
return 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _command_exists poetry; then
|
|
|
|
|
alias pr='poetry run'
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if _command_exists pyenv; then
|
|
|
|
|
alias pyvenvs='pyenv virtualenvs --bare --skip-aliases'
|
|
|
|
|
alias pyver='pyenv version'
|
|
|
|
|
alias pyvers='pyenv versions --skip-aliases'
|
|
|
|
|
alias pywhich='pyenv which'
|
|
|
|
|
fi
|
2026-08-03 02:02:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _command_exists vim; then
|
|
|
|
|
alias v=vim
|
|
|
|
|
_command_exists sudoedit && alias sv=sudoedit
|
|
|
|
|
fi
|