Skip to content

Instantly share code, notes, and snippets.

@mrahtz
Created March 9, 2019 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrahtz/4fb0306bfbc914290b5cefc76c3c5f20 to your computer and use it in GitHub Desktop.
Save mrahtz/4fb0306bfbc914290b5cefc76c3c5f20 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit
server=$1
remote_paths="$server:\""
for remote_path in "${@:2}"; do
remote_paths="$remote_paths '$remote_path'"
done
remote_paths="$remote_paths\""
if test $(find ~/.tr_timestamp -atime -5s); then
exit
fi
touch ~/.tr_timestamp
to_dir=$(mktemp -d)
echo -n $to_dir | pbcopy
cmd="rsync -av $remote_paths '$to_dir' && open '$to_dir'"
script_name=$(mktemp)
echo $cmd > $script_name
bash_cmd="/bin/bash '$script_name'"
script="tell application \"iTerm2\"
create window with default profile command \"$bash_cmd\"
end tell"
osascript -e "$script"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment