init.zsh 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # Defines Docker aliases.
  3. #
  4. # Author:
  5. # François Vantomme <akarzim@gmail.com>
  6. #
  7. # Return if requirements are not found.
  8. if (( ! $+commands[docker] )); then
  9. return 1
  10. fi
  11. #
  12. # Functions
  13. #
  14. # Set Docker Machine environment
  15. function dkme {
  16. if (( ! $+commands[docker-machine] )); then
  17. return 1
  18. fi
  19. eval $(docker-machine env $1)
  20. }
  21. # Set Docker Machine default machine
  22. function dkmd {
  23. if (( ! $+commands[docker-machine] )); then
  24. return 1
  25. fi
  26. pushd ~/.docker/machine/machines
  27. if [[ ! -d $1 ]]; then
  28. echo "Docker machine '$1' does not exists. Abort."
  29. popd
  30. return 1
  31. fi
  32. if [[ -L default ]]; then
  33. eval $(rm -f default)
  34. elif [[ -d default ]]; then
  35. echo "A default machine already exists. Abort."
  36. popd
  37. return 1
  38. elif [[ -e default ]]; then
  39. echo "A file named 'default' already exists. Abort."
  40. popd
  41. return 1
  42. fi
  43. eval $(ln -s $1 default)
  44. popd
  45. }
  46. # Source module files.
  47. source "${0:h}/alias.zsh"