blob: 6f25d781fe748ff82ed4dcde64c972d10bb193c9 (
plain)
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
|
function pp --description 'safely execute content from the clipboard'
# fish version of https://github.com/Aaronmsv/PastejackingProtection
if set -q WAYLAND_DISPLAY
set -f clip_cmd wl-paste
else if set -q DISPLAY
set -f clip_cmd "xclip -o"
else
echo "No graphical session detected" >&2
return 1
end
set -f clip_exe (string split -f 1 " " $clip_cmd)
if not type -q (string split -f 1 " " $clip_exe)
echo "please install $clip_exe" >&2
return 1
end
set -f script ($clip_cmd)
echo "$script" | cat -A
echo -e "\nExecute? (y/N): "
read execute
if test "$execute" = "y"
eval $script
end
end
|