2016-08-22 11:04:24 +01:00
|
|
|
# Some aliases
|
|
|
|
|
|
|
|
# v is shorter
|
|
|
|
alias v="$EDITOR"
|
2024-05-31 14:56:54 +01:00
|
|
|
alias vdc="$EDITOR docker-compose.yml"
|
2016-08-22 11:04:24 +01:00
|
|
|
|
|
|
|
# htop is better
|
|
|
|
alias top="htop"
|
|
|
|
|
|
|
|
# Vim like alias
|
|
|
|
alias :q="exit"
|
|
|
|
|
|
|
|
# Avoid typos
|
|
|
|
alias ake="make"
|
|
|
|
|
2017-04-20 14:46:50 +01:00
|
|
|
# cake is way more stylish than cmake
|
|
|
|
alias cake="cmake"
|
|
|
|
|
2016-08-22 11:04:24 +01:00
|
|
|
# My pdf reader
|
|
|
|
alias pdf="evince"
|
|
|
|
|
|
|
|
# clean for cmake files
|
2017-01-04 12:53:54 +00:00
|
|
|
alias cclean='rm -rf `find . -name "CMakeCache.txt"` `find . -name "cmake_install.cmake"` `find . -name "CMakeFiles"` `find . -name "Makefile"`'
|
2016-08-22 11:04:24 +01:00
|
|
|
|
|
|
|
# Some cd aliases
|
|
|
|
alias cd..="cd .."
|
|
|
|
alias cd...="cd ../.."
|
|
|
|
alias cd....="cd ../../.."
|
2018-05-02 08:32:22 +01:00
|
|
|
|
2024-01-09 10:04:55 +00:00
|
|
|
# Colored ip
|
|
|
|
alias ip="ip -c"
|
|
|
|
|
2018-05-02 08:32:22 +01:00
|
|
|
# Alias for ls
|
2018-03-29 07:29:00 +01:00
|
|
|
command -v exa > /dev/null 2>&1
|
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
2018-03-29 07:31:03 +01:00
|
|
|
LS_COLORS=""
|
2018-03-29 07:29:00 +01:00
|
|
|
alias ls="exa -h --group-directories-first"
|
2018-03-29 08:30:40 +01:00
|
|
|
alias lt="ls -lT"
|
2018-03-29 07:29:00 +01:00
|
|
|
else
|
|
|
|
alias ls="ls -h --color --group-directories-first"
|
|
|
|
fi
|
2017-12-21 09:35:22 +00:00
|
|
|
alias l="ls"
|
2016-08-31 09:02:52 +01:00
|
|
|
alias sl="ls"
|
2016-08-22 11:04:24 +01:00
|
|
|
alias lsd="ls"
|
2019-08-22 14:16:35 +01:00
|
|
|
alias la="ls -lah"
|
2019-10-09 10:34:54 +01:00
|
|
|
alias u="update"
|
2020-01-15 13:00:06 +00:00
|
|
|
alias gs="gst"
|
2016-09-08 08:16:44 +01:00
|
|
|
|
|
|
|
# Jump
|
|
|
|
alias j="jump"
|
2017-03-13 09:13:13 +00:00
|
|
|
|
2018-10-11 10:16:45 +01:00
|
|
|
# Disable bat paging
|
|
|
|
alias bat="bat --paging=never"
|
|
|
|
|
2020-02-17 13:59:58 +00:00
|
|
|
alias rg="rg -uu"
|
|
|
|
|
2021-10-18 15:07:44 +01:00
|
|
|
# Aliases for pass
|
|
|
|
alias p="pass"
|
|
|
|
alias pc="pass --clip"
|
|
|
|
|
2019-02-11 16:40:33 +00:00
|
|
|
# mkdir && cd
|
|
|
|
mkcd() {
|
|
|
|
mkdir $1 && cd $1
|
|
|
|
}
|
|
|
|
|
2022-04-19 10:25:37 +01:00
|
|
|
# which && cd
|
|
|
|
cdw() {
|
|
|
|
f=`which $1`
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
cd `dirname $f`
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-06-21 23:28:02 +01:00
|
|
|
# Numbat shortcut
|
|
|
|
alias nb=numbat
|
|
|
|
|
2017-03-13 09:13:13 +00:00
|
|
|
# Initialize thefuck
|
2017-03-23 16:07:35 +00:00
|
|
|
command -v thefuck > /dev/null 2>&1
|
|
|
|
|
|
|
|
# fuck aliases
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
eval $(thefuck --alias)
|
|
|
|
fi
|
2018-09-25 19:34:30 +01:00
|
|
|
|
2023-02-02 17:11:52 +00:00
|
|
|
# Docker and kubernetes aliases
|
|
|
|
command -v k9s > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2023-02-17 14:34:43 +00:00
|
|
|
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
|
|
|
|
}
|
2023-02-02 17:11:52 +00:00
|
|
|
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"
|
2023-03-08 14:12:21 +00:00
|
|
|
alias dcb="docker-compose build"
|
|
|
|
alias dcp="docker-compose build && docker-compose push"
|
2023-02-02 17:11:52 +00:00
|
|
|
alias dcu="docker-compose up -d --build --remove-orphans"
|
2023-02-03 13:15:03 +00:00
|
|
|
alias dcd="docker-compose down"
|
2023-10-27 13:25:34 +01:00
|
|
|
alias dcr="docker-compose down && docker-compose up -d --build --remove-orphans"
|
2023-02-02 17:11:52 +00:00
|
|
|
fi
|
|
|
|
|
2023-02-17 08:50:47 +00:00
|
|
|
command -v kubectl > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
|
2023-11-13 10:50:23 +00:00
|
|
|
if [ -d $HOME/.config/polymny ]; then
|
|
|
|
export PATH=$HOME/.config/polymny/bin:$PATH
|
|
|
|
fi
|
|
|
|
|
2023-03-13 09:50:09 +00:00
|
|
|
if [ -f $HOME/.kubes/current-cube ]; then
|
|
|
|
export KUBECONFIG=$(cat $HOME/.kubes/current-cube)
|
|
|
|
fi
|
|
|
|
|
2023-02-17 08:50:47 +00:00
|
|
|
# Sets the kube config
|
|
|
|
kube() {
|
|
|
|
local kube_config=$HOME/.kubes/$1/config
|
|
|
|
if [ $# -ne 1 ]; then
|
2023-04-22 10:08:04 +01:00
|
|
|
rm ~/.kubes/current-cube
|
|
|
|
export KUBECONFIG=""
|
2023-02-17 08:50:47 +00:00
|
|
|
elif [ ! -f $kube_config ]; then
|
|
|
|
echo >&2 error: no such kube config: $kube_config
|
|
|
|
return 1
|
|
|
|
else
|
2023-03-13 09:50:09 +00:00
|
|
|
echo $kube_config > ~/.kubes/current-cube
|
2023-02-17 08:50:47 +00:00
|
|
|
export KUBECONFIG=$kube_config
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-02-17 14:37:29 +00:00
|
|
|
# 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
|
|
|
|
}
|
|
|
|
|
2023-02-17 08:50:47 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-11 19:54:07 +00:00
|
|
|
# change to git directory
|
|
|
|
cdg() {
|
|
|
|
local newdir
|
2020-01-08 09:20:09 +00:00
|
|
|
newdir=$(CLICOLOR_FORCE=1 pgd $1) && cd $newdir
|
2019-02-11 19:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_cdg() {
|
|
|
|
_arguments "1: :($( cat $GCLONE_PATH/.cdgcache | rev | cut -d '/' -f 1 | rev))"
|
|
|
|
}
|
|
|
|
|
2019-05-18 12:00:05 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-02-11 19:54:07 +00:00
|
|
|
compdef _cdg cdg
|