unixconf/configurations/.zsh_functions

74 lines
1.4 KiB
Bash

#!/usr/bin/bash
assignProxy(){
PROXY_ENV=("http_proxy" "ftp_proxy" "https_proxy" "all_proxy" "no_proxy" "HTTP_PROXY" "HTTPS_PROXY" "FTP_PROXY" "NO_PROXY" "ALL_PROXY")
for envar in $PROXY_ENV
do
export $envar=$1
done
git config --global http.proxy "$1"
}
proxyclear(){
assignProxy "" # This is what 'unset' does.
echo "Proxy desactivé."
}
proxyfac(){
proxy_value="http://www-cache.ujf-grenoble.fr:3128"
assignProxy $proxy_value
echo "Proxy activé."
}
function cdfind() {
goto=$@;
IFS='
'
lall=( $(find . -iname "$goto*" -type d -readable 2>/dev/null) )
if [[ ${#lall[*]} == 0 ]]; then
echo "Aucune valeur trouvée";
elif [[ ${#lall[*]} == 1 ]]; then
cd "${lall[0]}";
else
for i in $(seq 1 $((${#lall[*]})) ); do
echo "[$i] - ${lall[$(( $i - 1 ))]}";
done
read -p "#?" i
cd "${lall[ $(( $i - 1 )) ]}"
fi
IFS=' '
}
function up() {
LIMIT=$1
P="$PWD"
for ((i=1; i <= LIMIT; i++));do
P=$P/..
done
cd "$P"
}
function ssh_tmux() {
ssh -t "$1" tmux a || ssh -t "$1" tmux;
}
function translate() {
if [[ "$1" = -r ]]; then
/usr/bin/translate fr en "$2"
else
/usr/bin/translate en fr "$1"
fi
}
function rmcontainer() {
sudo docker ps -a | awk ' $1 != "CONTAINER" { print "sudo docker stop " $1 " && sudo docker rm " $1 }' | bash
}
function vpn() {
sudo systemctl $1 openvpn@client
}