Watch
1
0
Fork
You've already forked dotfiles
0
dotfiles/.config/shell/aliases
Alexander Hess 8f7cef086b
Add configuration for vim
- Add ~/.config/vim/vimrc
  + Configure basic stuff
  + Activate spell checks
  + Activate syntax highlighting and ruler
  + Show whitespace characters
  + Add various snippets for mouse handling,
    toggling line numbers, and search
  + Set `vim`-related directories inside
   ~/.config/vim and ~/.local/state/vim
- Integrate extra settings for Python files
  in ~/.config/vim/after/ftplugin/python.vim
  and ~/.config/vim/after/syntax/python.vim
- Add `vim` artifacts in ~/.config/git/ignore
2026-08-20 21:20:47 +02:00

190 lines
4.3 KiB
Shell

#!/bin/sh
# Aliases used in all kinds of shells
# 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
# Manage the bare `git` repository in ~/ holding the dotfiles
alias dotfiles='git --git-dir=$DOTFILES_DIR --work-tree=$HOME'
forget() { # the current history and restore $HISTFILE from disk
if [ -n "$BASH_VERSION" ]; then
history -c
history -r
elif [ -n "$ZSH_VERSION" ]; then
local _histsize=$HISTSIZE
HISTSIZE=0 # because shrinking the list to 0 discards all entries
HISTSIZE=$_histsize
fc -R "$HISTFILE"
fi
}
if [ -n "$ZSH_VERSION" ]; then
alias forget=' forget' # Leading space => The invocation itself is forgotten
fi
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'
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'
# 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
if _command_exists vim; then
alias v=vim
_command_exists sudoedit && alias sv=sudoedit
fi