My configuration files for Debian/Ubuntu applications
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

67 lines
1.6 KiB

  1. #!/usr/bin/env bash
  2. CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. HELPERS_DIR="$CURRENT_DIR/helpers"
  4. source "$HELPERS_DIR/plugin_functions.sh"
  5. source "$HELPERS_DIR/utility.sh"
  6. if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
  7. source "$HELPERS_DIR/tmux_echo_functions.sh"
  8. else # shell output functions
  9. source "$HELPERS_DIR/shell_echo_functions.sh"
  10. fi
  11. clone() {
  12. local plugin="$1"
  13. cd "$(tpm_path)" &&
  14. GIT_TERMINAL_PROMPT=0 git clone --recursive "$plugin" >/dev/null 2>&1
  15. }
  16. # tries cloning:
  17. # 1. plugin name directly - works if it's a valid git url
  18. # 2. expands the plugin name to point to a github repo and tries cloning again
  19. clone_plugin() {
  20. local plugin="$1"
  21. clone "$plugin" ||
  22. clone "https://git::@github.com/$plugin"
  23. }
  24. # clone plugin and produce output
  25. install_plugin() {
  26. local plugin="$1"
  27. local plugin_name="$(plugin_name_helper "$plugin")"
  28. if plugin_already_installed "$plugin"; then
  29. echo_ok "Already installed \"$plugin_name\""
  30. else
  31. echo_ok "Installing \"$plugin_name\""
  32. clone_plugin "$plugin" &&
  33. echo_ok " \"$plugin_name\" download success" ||
  34. echo_err " \"$plugin_name\" download fail"
  35. fi
  36. }
  37. install_plugins() {
  38. local plugins="$(tpm_plugins_list_helper)"
  39. for plugin in $plugins; do
  40. install_plugin "$plugin"
  41. done
  42. }
  43. verify_tpm_path_permissions() {
  44. local path="$(tpm_path)"
  45. # check the write permission flag for all users to ensure
  46. # that we have proper access
  47. [ -w "$path" ] ||
  48. echo_err "$path is not writable!"
  49. }
  50. main() {
  51. ensure_tpm_path_exists
  52. verify_tpm_path_permissions
  53. install_plugins
  54. exit_value_helper
  55. }
  56. main