My configuration files for Debian/Ubuntu applications
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

72 rindas
1.6 KiB

  1. #!/usr/bin/env bash
  2. # this script handles core logic of updating plugins
  3. CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  4. HELPERS_DIR="$CURRENT_DIR/helpers"
  5. source "$HELPERS_DIR/plugin_functions.sh"
  6. source "$HELPERS_DIR/utility.sh"
  7. if [ "$1" == "--tmux-echo" ]; then # tmux-specific echo functions
  8. source "$HELPERS_DIR/tmux_echo_functions.sh"
  9. else # shell output functions
  10. source "$HELPERS_DIR/shell_echo_functions.sh"
  11. fi
  12. # from now on ignore first script argument
  13. shift
  14. pull_changes() {
  15. local plugin="$1"
  16. local plugin_path="$(plugin_path_helper "$plugin")"
  17. cd "$plugin_path" &&
  18. GIT_TERMINAL_PROMPT=0 git pull &&
  19. GIT_TERMINAL_PROMPT=0 git submodule update --init --recursive
  20. }
  21. update() {
  22. local plugin="$1"
  23. $(pull_changes "$plugin" > /dev/null 2>&1) &&
  24. echo_ok " \"$plugin\" update success" ||
  25. echo_err " \"$plugin\" update fail"
  26. }
  27. update_all() {
  28. echo_ok "Updating all plugins!"
  29. echo_ok ""
  30. local plugins="$(tpm_plugins_list_helper)"
  31. for plugin in $plugins; do
  32. local plugin_name="$(plugin_name_helper "$plugin")"
  33. # updating only installed plugins
  34. if plugin_already_installed "$plugin_name"; then
  35. update "$plugin_name" &
  36. fi
  37. done
  38. wait
  39. }
  40. update_plugins() {
  41. local plugins="$*"
  42. for plugin in $plugins; do
  43. local plugin_name="$(plugin_name_helper "$plugin")"
  44. if plugin_already_installed "$plugin_name"; then
  45. update "$plugin_name" &
  46. else
  47. echo_err "$plugin_name not installed!" &
  48. fi
  49. done
  50. wait
  51. }
  52. main() {
  53. ensure_tpm_path_exists
  54. if [ "$1" == "all" ]; then
  55. update_all
  56. else
  57. update_plugins "$*"
  58. fi
  59. exit_value_helper
  60. }
  61. main "$*"