-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiterm2-rz.sh
executable file
·45 lines (40 loc) · 1.14 KB
/
iterm2-rz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# confirm that iTerm2 app's name is "iTerm" or "iTerm2"
osascript -e 'tell application "iTerm" to version' >/dev/null 2>&1 && app_name="iTerm" || app_name="iTerm2"
# confirm that choose folder or not
# you can set CHOOSE_FOLDER=true in your ~/.bashrc(not .zshrc or config.fish) to enable this feature
source "$HOME/.bashrc"
if [ -n "$CHOOSE_FOLDER" ] && [ "$CHOOSE_FOLDER" = true ]; then
# choose folder by using apple script
FILE=$(
osascript <<EOF
tell application "$app_name"
set thefile to choose folder with prompt "Files save to:"
set thefile to POSIX path of theFile
end tell
EOF
)
else
# fixed folder
FILE="$HOME/Downloads/"
fi
# $FILE format(folder name can have spaces):
# /Users/xxx/Downloads/folder
# /Users/xxx/Downloads/fol der
# echo $FILE
if [[ $FILE = "" ]]; then
echo Cancelled.
# Send ZModem cancel
echo -e \\x18\\x18\\x18\\x18\\x18
sleep 1
echo
echo \# Cancelled transfer
else
cd "$FILE"
# receive files from server by using rz
/usr/local/bin/rz -E -e -b --bufsize 4096
sleep 1
echo
echo
echo \# Files have been Sent to \-\> "$FILE"
fi