dotfiles/aliases

102 lines
2.2 KiB
Text

unalias -a
# Safety first
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
# Colorize output, make ls human readable and classify...
if [[ `uname` == Darwin ]]; then
alias dircolors='gdircolors'
alias ls='gls --color=auto -hF'
else
alias ls='ls --color=auto -hF'
# ...and standardize to macOS naming on Linux
alias open='xdg-open'
fi
# Disk utility aliases
alias df='df -h'
alias du='du -h'
# Colorize output and some exclusions
alias grep="grep --color=auto --exclude-dir={.git,artwork,node_modules,vendor}"
# Git functions
git_branch() {
(command git symbolic-ref -q HEAD || command git name-rev --name-only --no-undefined --always HEAD) 2>/dev/null
}
# Git aliases
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gb='git branch'
alias gc='git commit'
alias gca='git commit -a'
alias gcam='git commit -a --amend'
alias gcb='git checkout -b'
alias gcl='git clone'
alias gcm='git checkout master'
alias gco='git checkout'
alias fgco='git checkout $(git branch | sed "s/\*//" | fzf)'
alias gd='git diff'
alias gds='git diff --staged'
alias gf='git fetch'
alias gfm='git fetch origin master:master'
alias gl='git pull origin $(git_branch)'
alias glg='git log'
alias gm='git merge'
alias gmm='git merge master'
alias gmv='git mv'
alias gp='git push origin $(git_branch)'
alias gpf='git push origin $(git_branch) --force'
alias grb='git rebase'
alias grbm='git rebase master'
alias grm='git rm'
alias gst='git status'
# HTTPie aliases
alias GET='http'
alias POST='http POST'
alias HEAD='http HEAD'
# Nvim takeover
alias vim='nvim'
alias vimdiff='nvim -d'
# `ls` after `cd`
function cd {
builtin cd "$@" && ls
}
# Run `nvm` init script on demand to avoid constant slow downs
function nvm {
if [ -z ${NVM_DIR+x} ]; then
export NVM_DIR="$HOME/.nvm"
if [ -s "$NVM_DIR/nvm.sh" ]; then
source "$NVM_DIR/nvm.sh"
elif [ -s "/usr/share/nvm/init-nvm.sh" ]; then
source /usr/share/nvm/init-nvm.sh
fi
nvm "$@"
fi
}
# PID Port
function pp {
ss -lptn sport = :$1 | grep -Eo 'pid=[0-9]+' | cut -c5-
}
# function vim {
# BACKGROUND=$(xtermcontrol --get-bg)
#
# if [[ "$BACKGROUND" == "rgb:0000/2b2b/3636" ]]; then
# env vim --cmd "let theme = 'dark'" $@
# else
# env vim --cmd "let theme = 'light'" $@
# fi
# }