dotfiles/sh/.config/sh/alias
Marty Oehme 6380affb6f Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).

Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)

Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00

112 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