dotfiles/sh/.config/sh/alias

113 lines
2.4 KiB
Bash

#!/usr/bin/env sh
#
# Global aliases for any shell
exist() { type "$1" >/dev/null 2>&1; }
# Avoid aliases which I did not create -- unalias EVERYTHING
unalias -a
# v shorthand for neovim
alias v="nvim"
# exit shell mimicks vim
alias :q="exit"
# ls defaults
if exist exa; then
alias l="exa -l --git --git-ignore"
alias L="exa -hal --grid --git"
# a recursive tree
# - usually want to change levels recursed with -L2 -L3 or similar
alias ll="exa --tree -L2"
alias LL="exa -a --tree -L2"
else
alias l="ls -lhF"
alias L="ls -lAhF"
fi
# cd defaults
alias ..="cd .."
alias ...="cd ../.."
alias ~="cd ~"
# git alias
if exist git; then
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gb='git branch'
alias gbd='git branch -d'
alias gc='git commit -v'
alias gc!='git commit -v --amend'
alias gcn!='git commit -v --no-edit --amend'
alias gcm='git checkout master'
alias gcd='git checkout develop'
alias gcb='git checkout -b'
alias gco='git checkout'
alias gd='git diff'
alias gds='git diff --staged'
alias gi='git ignore'
alias glog='git log --stat'
alias glg='git log --oneline --decorate --graph'
alias glga='git log --oneline --decorate --graph --remotes --all'
alias glgp='git log --stat -p'
alias gf='git fetch'
alias gl='git pull'
alias gpn='git push --dry-run'
alias gp='git push'
alias gpf!='git push --force'
alias grv='git remote -v'
alias grs='git restore --staged'
alias grs!='git restore'
alias grbi='git rebase -i'
alias grbc='git rebase --continue'
alias gst='git status'
autoload -Uz is-at-least
if is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')"; then
alias gsta='git stash push'
else
alias gsta='git stash save'
fi
alias gstp='git stash pop'
alias gstl='git stash list'
fi
# clear my screen
alias cl="clear"
# Display current external ip address
alias myip="curl -s icanhazip.com"
# fzf
if exist fzf; then
# Display fuzzy-searchable history
alias fzf_history="history | fzf --tac --height 20"
# Fuzzy search packages to install
if exist yay; then
alias fzf_yay="yay -Slq | fzf -m --preview 'yay -Si {1}' | xargs -ro yay -S"
# Fuzzy uninstall packages
alias fzf_yayrns="yay -Qeq | fzf -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns"
fi
fi
# vifm
if exist vifm; then
alias vm=vifm
alias vmm='vifm ${PWD}'
# enable picture preview script
exist vifmrun && alias vifm=vifmrun
fi