-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-gist.sh
More file actions
executable file
·37 lines (33 loc) · 914 Bytes
/
upload-gist.sh
File metadata and controls
executable file
·37 lines (33 loc) · 914 Bytes
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
#!/bin/bash
process_files() {
while IFS= read -r filename; do
# Skip empty lines
[ -z "$filename" ] && continue
# Find the full path of the file
filepath=$(find . -name "$filename" -type f)
if [ -n "$filepath" ]; then
echo "Creating gist for $filename from $filepath"
gh gist create "$filepath" --filename "$filename"
else
echo "Warning: Could not find $filename"
fi
done
}
# Check if input is being piped in
if [ -p /dev/stdin ]; then
# Process piped input
process_files
elif [ "$1" ]; then
# Process input file from argument
if [ -f "$1" ]; then
process_files < "$1"
else
echo "Error: File $1 not found"
exit 1
fi
else
echo "Usage: $0 <filename> or pipe input to script"
echo "Example: $0 file_list"
echo "Example: cat file_list | $0"
exit 1
fi