190 lines
3.8 KiB
Bash
190 lines
3.8 KiB
Bash
# Some aliases
|
|
|
|
# v is shorter
|
|
alias v="$EDITOR"
|
|
|
|
# htop is better
|
|
alias top="htop"
|
|
|
|
# Vim like alias
|
|
alias :q="exit"
|
|
|
|
# Avoid typos
|
|
alias ake="make"
|
|
|
|
# cake is way more stylish than cmake
|
|
alias cake="cmake"
|
|
|
|
# My pdf reader
|
|
alias pdf="evince"
|
|
|
|
# clean for cmake files
|
|
alias cclean='rm -rf `find . -name "CMakeCache.txt"` `find . -name "cmake_install.cmake"` `find . -name "CMakeFiles"` `find . -name "Makefile"`'
|
|
|
|
# Some cd aliases
|
|
alias cd..="cd .."
|
|
alias cd...="cd ../.."
|
|
alias cd....="cd ../../.."
|
|
|
|
# Colored ip
|
|
alias ip="ip -c"
|
|
|
|
# Alias for ls
|
|
command -v exa > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
LS_COLORS=""
|
|
alias ls="exa -h --group-directories-first"
|
|
alias lt="ls -lT"
|
|
else
|
|
alias ls="ls -h --color --group-directories-first"
|
|
fi
|
|
alias l="ls"
|
|
alias sl="ls"
|
|
alias lsd="ls"
|
|
alias la="ls -lah"
|
|
alias u="update"
|
|
alias gs="gst"
|
|
|
|
# Jump
|
|
alias j="jump"
|
|
|
|
# Disable bat paging
|
|
alias bat="bat --paging=never"
|
|
|
|
alias rg="rg -uu"
|
|
|
|
# Aliases for pass
|
|
alias p="pass"
|
|
alias pc="pass --clip"
|
|
|
|
# mkdir && cd
|
|
mkcd() {
|
|
mkdir $1 && cd $1
|
|
}
|
|
|
|
# which && cd
|
|
cdw() {
|
|
f=`which $1`
|
|
if [ $? -eq 0 ]; then
|
|
cd `dirname $f`
|
|
fi
|
|
}
|
|
|
|
# Initialize thefuck
|
|
command -v thefuck > /dev/null 2>&1
|
|
|
|
# fuck aliases
|
|
if [ $? -eq 0 ]; then
|
|
eval $(thefuck --alias)
|
|
fi
|
|
|
|
# Docker and kubernetes aliases
|
|
command -v k9s > /dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
kns() {
|
|
local kube_config
|
|
if [ -z $KUBECONFIG ]; then
|
|
kube_config=$HOME/.kube/config
|
|
else
|
|
kube_config=$KUBECONFIG
|
|
fi
|
|
if [ -f $kube_config ]; then
|
|
k9s
|
|
else
|
|
echo >&2 error: $kube_config does not exist
|
|
return 1
|
|
fi
|
|
}
|
|
fi
|
|
|
|
command -v lazydocker > /dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
alias ld="lazydocker"
|
|
fi
|
|
|
|
command -v docker-compose > /dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
alias dc="docker-compose"
|
|
alias dcb="docker-compose build"
|
|
alias dcp="docker-compose build && docker-compose push"
|
|
alias dcu="docker-compose up -d --build --remove-orphans"
|
|
alias dcd="docker-compose down"
|
|
alias dcr="docker-compose down && docker-compose up -d --build --remove-orphans"
|
|
fi
|
|
|
|
command -v kubectl > /dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
|
|
if [ -d $HOME/.config/polymny ]; then
|
|
export PATH=$HOME/.config/polymny/bin:$PATH
|
|
fi
|
|
|
|
if [ -f $HOME/.kubes/current-cube ]; then
|
|
export KUBECONFIG=$(cat $HOME/.kubes/current-cube)
|
|
fi
|
|
|
|
# Sets the kube config
|
|
kube() {
|
|
local kube_config=$HOME/.kubes/$1/config
|
|
if [ $# -ne 1 ]; then
|
|
rm ~/.kubes/current-cube
|
|
export KUBECONFIG=""
|
|
elif [ ! -f $kube_config ]; then
|
|
echo >&2 error: no such kube config: $kube_config
|
|
return 1
|
|
else
|
|
echo $kube_config > ~/.kubes/current-cube
|
|
export KUBECONFIG=$kube_config
|
|
fi
|
|
}
|
|
|
|
# Shortcut for kubectl
|
|
kctl() {
|
|
local kube_config
|
|
if [ -z $KUBECONFIG ]; then
|
|
kube_config=$HOME/.kube/config
|
|
else
|
|
kube_config=$KUBECONFIG
|
|
fi
|
|
if [ -f $kube_config ]; then
|
|
kubectl $@
|
|
else
|
|
echo >&2 error: $kube_config does not exist
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
fi
|
|
|
|
# change to git directory
|
|
cdg() {
|
|
local newdir
|
|
newdir=$(CLICOLOR_FORCE=1 pgd $1) && cd $newdir
|
|
}
|
|
|
|
_cdg() {
|
|
_arguments "1: :($( cat $GCLONE_PATH/.cdgcache | rev | cut -d '/' -f 1 | rev))"
|
|
}
|
|
|
|
cratefmt() {
|
|
local current_dir=$PWD
|
|
|
|
# Find cargo.toml
|
|
while [ ! -f Cargo.toml ] && [ $PWD != "/" ]; do
|
|
cd ..
|
|
done
|
|
|
|
if [ -f Cargo.toml ]; then
|
|
rustfmt --edition 2018 `find src -name "*.rs"`
|
|
else
|
|
echo -e "\033[1;31merror:\033[0m\033[1m can't find Cargo.toml\033[0m"
|
|
cd $current_dir
|
|
return 1
|
|
fi
|
|
|
|
cd $current_dir
|
|
}
|
|
|
|
compdef _cdg cdg
|