Skip to content

Commit 0614cd1

Browse files
committedNov 22, 2024·
Adding run-and-xclip helper
1 parent 1c3a55f commit 0614cd1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎bin/run-and-xclip

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# A little helper to run a command and "cut" its output to X clipboard
4+
# to be pasted into github issue within <details>
5+
#
6+
7+
cmd=( "$@" )
8+
9+
(
10+
echo "<details><summary>$@</summary>"
11+
echo
12+
echo '```'
13+
"$@"
14+
echo '```'
15+
echo
16+
echo "</details>"
17+
) 2>&1 | xclip -i
18+
nlines=$(xclip -o | wc -l)
19+
echo "I: copied $nlines into clipboard"
20+
21+
if [ "$nlines" -lt 10 ]; then
22+
echo "D: full output"
23+
xclip -o
24+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.