#!/bin/sh # Allows to select a host to send files to through scp hostsfile="$HOME/.hosts" host="$(sed '/^#/d; /^\s*$/d' "$hostsfile" | cut -d'#' -f1 | fzf)" || exit 0 hostline="$(grep "^${host}#" "$hostsfile")" hostname="$(echo "$hostline" | cut -d'#' -f1)" hostaddress="$(echo "$hostline" | cut -d'#' -f2)" hostport="$(echo "$hostline" | cut -d'#' -f3)" hostpass="$(echo "$hostline" | cut -d'#' -f4)" targetPath="$(echo "$hostline" | cut -d'#' -f5)" echo "Sending to $hostname" [ "$hostpass" ] && pass -c "$hostpass" if [ -n "$hostport" ]; then scp -r -P "$hostport" "$@" "${hostaddress}:${targetPath}" else scp -r "$@" "${hostaddress}:${targetPath}" # No quotes here! fi