dotfiles/home/.dotfiles/aliases
Marcus Noble 855c741b0b
Better handling of installed git
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
2022-09-10 19:44:22 +01:00

75 lines
1.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Rename existing tools
alias _cat=`which cat`
alias _curl=`which curl`
alias _ls="/bin/ls"
alias _grep="/bin/grep"
alias _diff="/usr/bin/diff"
alias _du=`which du`
alias _df=`which df`
alias _find=`which find`
alias _top=`which top`
alias _ps="/bin/ps"
alias _dig=`which dig`
alias _readlink=`which readlink`
alias _git=`which git`
if command -v $(brew --prefix)/bin/git &>/dev/null; then
alias _git=$(brew --prefix)/bin/git
fi
# Aliases
alias cat='bat '
alias curl='curlie'
alias ls='exa --group-directories-first --icons --header --git --ignore-glob=.git'
alias grep='rg'
alias diff='delta'
alias du='dust'
alias df='duf -hide special'
alias find='fd'
alias bandwhich='sudo bandwhich'
alias top='btm'
alias ps='procs'
alias dig='doggo'
alias kubectx='switch'
alias kctx='switch'
alias machine-info='macchina -t Boron --bar'
alias watch='watch '
alias tmp='cd $(mktemp -d)'
which greadlink &>/dev/null && alias readlink=`which greadlink`
lt() {
DEPTH=$(echo $1 | grep "^[0-9]*$")
if [ "$DEPTH" = "" ]; then
DEPTH=2
else
shift
fi
ls -l --tree -L $DEPTH -I ".git|cache|log|logs|node_modules|vendor" $@
}
git() {
if [ "$1" = "take" ]; then # Git clone then cd into new directory
if [ $# -gt 2 ]; then
_git clone ${@:2}
cd $3
else
ORG=$(echo $2 | sed -e 's|https://||' -e 's|/| |g' -e 's|:| |g' | cut -f 2 -d ' ')
REPO=$(echo $2 | sed -e 's|https://||' -e 's|/| |g' -e 's|:| |g' | cut -f 3 -d ' ' | xargs basename -s .git)
DST="${HOME}/Code/${ORG}/${REPO}"
mkdir -p ${DST}
_git clone $2 ${DST}
cd ${DST}
fi
elif [ "$1" = "commit" ]; then # Sign all commits
shift
_git commit -s $@
elif [ "$1" = "co" ]; then # Sign all commits
shift
_git checkout -b $@
else
_git $@
fi
}