58 lines
1.0 KiB
Bash
58 lines
1.0 KiB
Bash
function docker(){
|
|
sudo docker "$@"
|
|
}
|
|
|
|
function pw(){
|
|
FILE="$1"
|
|
|
|
[[ -z "$PWHOME" ]] && printf "\$PWHOME not set\n" && return
|
|
|
|
[[ -z "$FILE" ]] && FILE="web.gpg"
|
|
|
|
if [[ ! "${FILE: -4}" == ".gpg" ]];then
|
|
FILE="${FILE}.gpg"
|
|
fi
|
|
cd "$PWHOME"
|
|
vi "$FILE"
|
|
|
|
cd "$OLDPWD"
|
|
}
|
|
|
|
_pw_completion()
|
|
{
|
|
local cur prev suggestions
|
|
[[ -z "$PWHOME" ]] && return
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
cd "$PWHOME"
|
|
suggestions="$(ls *.gpg)"
|
|
cd "$OLDPWD"
|
|
if [[ "$prev" != "pw" ]];then
|
|
COMPREPLY=()
|
|
else
|
|
COMPREPLY=( $(compgen -W "${suggestions}" -- ${cur}) )
|
|
fi
|
|
}
|
|
complete -F _pw_completion pw
|
|
|
|
function doh()
|
|
{
|
|
local options
|
|
SUDO=sudo
|
|
options=(start stop restart status)
|
|
if [[ ! " ${options[@]} " =~ " ${1} " ]]; then
|
|
echo "wrong option, valid: ${options[@]}"
|
|
return
|
|
fi
|
|
if [[ "$1" == "status" ]]; then
|
|
systemctl status local-doh-proxy
|
|
else
|
|
sudo systemctl "$1" local-doh-proxy
|
|
fi
|
|
}
|
|
|
|
function copy_k8s_token(){
|
|
grep "id-token" ~/.kube/config | awk '{print $2}' | xclip -sel clip
|
|
}
|
|
|