#!/bin/sh # Use neovim for vim if present [ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d" # Use $XINITRC variable if file exists. [ -f "$XINITRC" ] && alias startx="startx $XINITRC" # doas not required for some system commands for x in mount umount sv pacman updatedb su ; do alias $x="doas $x" done # Verbosity and settings that you pretty much just always are going to want. alias \ cp="cp -iv" \ mv="mv -iv" \ rm="rm -vI" \ bc="bc -ql" \ mkd="mkdir -pv" \ yt="youtube-dl --add-metadata -i" \ yta="yt -x -f bestaudio/best" \ ffmpeg="ffmpeg -hide_banner" \ tmux="tmux -f ~/.config/tmux/tmux.conf" # Colorize commands when possible. alias \ ls="ls -hN --color=auto --group-directories-first" \ grep="grep --color=auto" \ diff="diff --color=auto" \ ccat="highlight --out-format=ansi" # Abbreviating long commands alias \ ka="killall" \ YT="youtube-viewer" \ sdn="doas shutdown -h now" \ e="$EDITOR" \ v="$EDITOR" \ cl="clear" \ p="doas pacman" \ z="zathura" \ ll="ls -l" \ la="ls -al" \ ag="alias | grep" \ lc="clone_from_labs" \ gc="clone_from_github" \ dgit="git --git-dir ~/.config/dotfiles/.git --work-tree=$HOME" \ sudo=doas \ .z="source ~/.config/shell/profile" # Clone from labs function clone_from_labs() { git clone "git@labs.scarif.space:chris/$1" "${@:2}" } # Clone from github function clone_from_github() { git clone "https://github.com/$1" "${@:2}" } # Check if main exists and use instead of master function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return local branch for branch in main trunk; do if command git show-ref -q --verify refs/heads/$branch; then echo $branch return fi done echo master } # Git aliases alias \ g="git" \ ga="git add" \ dga="dgit add -f" \ dgcm="dgit commit -m" \ dgs="dgit status" \ dgd="dgit diff" \ dgdc="dgit diff --cached" \ dgp="dgit push" \ dgup="dgit pull --rebase" \ gaa="git add --all" \ gb="git branch" \ gba="git branch -a" \ gbd="git branch -d" \ gbD="git branch -D" \ gbs="git bisect" \ gbsb="git bisect bad" \ gbsg="git bisect good" \ gbsr="git bisect reset" \ gbss="git bisect start" \ gc="git commit -v" \ gc!="git commit -v --amend" \ gcn!="git commit -v --no-edit --amend" \ gca="git commit -v -a" \ gca!="git commit -v -a --amend" \ gcan!="git commit -v -a --no-edit --amend" \ gcam="git commit -a -m" \ gcm="git checkout $(git_main_branch)" \ gco="git checkout" \ gcb="git checkout -b" \ gf="git fetch" \ gfa="git fetch --all --prune" \ gd="git diff" \ gdc="git diff --cached" \ gl="git pull" \ glg="git log --stat" \ glgg="git log --graph" \ glo="git log --oneline --decorate" \ glgp="git log --stat -p" \ gm="git merge" \ gp="git push" \ grb="git rebase" \ gsb="git status -sb" \ gsh="git show" \ gsps="git show --pretty=short --show-signature" \ gsta="git stash push" \ gstaa="git stash apply" \ gstp="git stash pop" \ gstl="git stash list" \ gsts="git stash show --text" \ gup="git pull --rebase" \ nah="git reset --hard; git clean -df" \ gapa="git add --patch -A" \ gun="git reset --" \ glgm="git log --stat --author=christopher" \ glgpm="git log --stat -p --author=christopher"