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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
# pt-ul — Upload files from local to remote via par-term
#
# Sends iTerm2 OSC 1337 RequestUpload escape sequence. par-term shows a
# native file picker, user selects a file, and the data is sent back
# as a base64-encoded response.
#
# Usage:
# pt-ul [destination_dir]
#
# Works over SSH on any remote host. Only requires: base64, printf, cat
# Detect tmux/screen for passthrough wrapping
# Print escape sequence with optional tmux passthrough
# Destination directory (default: current directory)
_dest_dir=""
if [; then
fi
# Save terminal settings and set raw mode for reading response
_old_tty=""
if ; then
_old_tty=
||
fi
# Restore terminal on exit
# Send upload request
# Read response - terminal sends base64-encoded tar.gz data on a single line
# Format: base64(tar.gz) + newline, or "abort" if user cancelled
_response=""
while ; do
_response=""
break
done
# Restore terminal before processing
# Check for empty response (cancelled)
if [ || [; then
fi
# Decode the response
# Response is base64-encoded tar.gz data
_tmpfile=
|
if [; then
fi
# Extract to destination
if ; then
_rc=
else
fi
if [; then
else
fi