You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. declare -r fifo='/tmp/sshget.fifo'
  3. declare -A domains=()
  4. declare -A paths=()
  5. declare -a files=()
  6. declare -A requests=()
  7. cleanup() {
  8. [[ -e "$fifo" ]] && rm "$fifo"
  9. }
  10. trap cleanup SIGHUP SIGINT SIGTERM
  11. mkfifo "$fifo"
  12. for a in "$@"; do
  13. host="${a%%:*}"
  14. path="${a##*:}"
  15. domains+=( ["$a"]="$host" )
  16. paths+=( ["$a"]="$path" )
  17. shift
  18. done
  19. for s in "${!domains[@]}"; do
  20. ssh "${domains[$s]}" "find ${paths[$s]}" | sed -r "s|^(.*)|${domains[$s]}:\"\1\"|" >> "$fifo" &
  21. done
  22. mapfile -t files < <( fzf -e --inline-info --multi --cycle --query="$*" < "$fifo" )
  23. if (( ${#files[@]} )); then
  24. rsync -auvzP -e ssh "${files[@]}" .
  25. fi
  26. cleanup