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
#!/bin/sh
# pt-dl — Download files from remote to local via par-term
#
# Uses iTerm2 OSC 1337 File protocol with inline=0 to trigger
# a native save dialog in par-term.
#
# Usage:
# pt-dl <file> [file2 ...]
# cat data | pt-dl --name output.txt
#
# Works over SSH on any remote host. Only requires: base64, wc, printf, cat, basename
# Detect tmux/screen for passthrough wrapping
# Print escape sequence with optional tmux passthrough
# Send a single file via OSC 1337 File protocol
# Args: $1 = filename, stdin = file data
# Parse arguments
_stdin_mode=0
_name=""
if [; then
# Check if stdin is a pipe
if [; then
fi
fi
# Check for --name flag (stdin mode)
if [; then
if [; then
fi
_name=""
_stdin_mode=1
fi
if [; then
# Read from stdin
else
# Process each file argument
for; do
if [; then
continue
fi
if [; then
continue
fi
_basename=
done
fi