From 7c2dab07b51336a671750871f78c3f1c42c35743 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Wed, 2 Nov 2022 16:20:50 +0100 Subject: Fixed scp.sh --- scp.sh | 21 +++++++++++++-------- selectAudioSink.sh | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/scp.sh b/scp.sh index 6365187..bf05ce0 100755 --- a/scp.sh +++ b/scp.sh @@ -2,13 +2,18 @@ # Allows to select a host to send files to through scp hostsfile="$HOME/.hosts" -hostnames="$(sed '/^#.*$/d; /^$/d' < "$hostsfile" | cut -d'#' -f1 | fzf)" || exit 0 -host="$(grep "$hostnames" < "$hostsfile")" -hostname="$(echo "$host" | cut -d'#' -f1)" -hostaddress="$(echo "$host" | cut -d'#' -f2)" -hostport="$(echo "$host" | cut -d'#' -f3)" -hostpass="$(echo "$host" | cut -d'#' -f4)" -targetPath="$(echo "$host" | cut -d'#' -f5)" +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" -[ "$hostport" ] && scp -r -P $hostport "$@" $hostaddress:$targetPath || scp -r "$@" $hostaddress:$targetPath # No quotes here! +if [ -n "$hostport" ]; then + scp -r -P "$hostport" "$@" "${hostaddress}:${targetPath}" +else + scp -r "$@" "${hostaddress}:${targetPath}" # No quotes here! +fi diff --git a/selectAudioSink.sh b/selectAudioSink.sh index e5b0c68..0dcbeba 100755 --- a/selectAudioSink.sh +++ b/selectAudioSink.sh @@ -4,6 +4,8 @@ # # Sets an audio sink. +LANG='en_US.UTF-8' + port="$(pactl list sinks | sed -n '/Ports/,/Active Port/p' | sed '/Ports/d;/Active/d;s/:.*$//;s/^\s*//' | -- cgit v1.2.1