Created
March 9, 2020 07:47
-
-
Save fanch317/77e85d4389b5f830dde26ef16bf80f9e to your computer and use it in GitHub Desktop.
End of .zshrc for h function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h_func(){ | |
OLD_IFS=${IFS}; IFS=" | |
"; | |
if [ $1 ]; then | |
HOSTS=`cat /usr/local/etc/hosts.txt | grep $1` | |
RESULT=`cat /usr/local/etc/hosts.txt | grep $1 | wc -l` | |
if [ "$RESULT" = "1" ]; then | |
address=`echo $HOSTS | sed 's/\([^ #]*\) \?\([^ #]*\) \?#\?\(.*\)\?/\1/'` | |
echo "" && echo -e "\e[1mConnexion a $address\e[0m" && echo "" | |
commentaire=`echo $HOSTS | sed 's/\([^ #]*\) \?\([^ #]*\) \?#\?\(.*\)\?/\3/'` | |
[ -z $commentaire ] || echo -e "\e[0;33mRemarque : $commentaire\e[0m" | |
ssh $address | |
else | |
PS3="Your choice: " | |
select FILENAME in $HOSTS; | |
do | |
case $FILENAME in | |
"0") | |
echo "Exiting." | |
break | |
;; | |
"") | |
echo "Exiting." | |
break | |
;; | |
*) | |
address=`echo $FILENAME | sed 's/\([^ #]*\) \?\([^ #]*\) \?#\?\(.*\)\?/\1/'` | |
echo "" && echo -e "\e[1mConnexion a $address\e[0m" && echo "" | |
commentaire=`echo $FILENAME | sed 's/\([^ #]*\) \?\([^ #]*\) \?#\?\(.*\)\?/\3/'` | |
[ -z $commentaire ] || echo -e "\e[0;33mRemarque : $commentaire\e[0m" | |
#sshrc $address | |
ssh $address | |
break | |
;; | |
esac | |
done | |
fi | |
IFS=$OLD_IFS | |
else | |
HOSTS=`cat /usr/local/etc/hosts.txt` | |
fi | |
} | |
alias h=h_func | |
alias f65="ssh f.cariou@192.168.205.99" | |
export DOCKER_HOST=tcp://localhost:2375 | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment