aboutsummaryrefslogtreecommitdiff
path: root/config/fish
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2022-09-05 11:04:04 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2022-09-05 11:04:04 +0200
commit7eb039914c8819e2b7c665db81dbaed73075dbdf (patch)
tree2b4290a6273117be221b35a859050cf7db4255c0 /config/fish
parent1ce3bc24f27247b1fcb77beb850cdcf1075e8fc4 (diff)
downloaddotfiles-7eb039914c8819e2b7c665db81dbaed73075dbdf.tar.gz
dotfiles-7eb039914c8819e2b7c665db81dbaed73075dbdf.zip
fish: add wayland support to pp
Diffstat (limited to 'config/fish')
-rw-r--r--config/fish/functions/pp.fish34
1 files changed, 22 insertions, 12 deletions
diff --git a/config/fish/functions/pp.fish b/config/fish/functions/pp.fish
index 6cd9161..6f25d78 100644
--- a/config/fish/functions/pp.fish
+++ b/config/fish/functions/pp.fish
@@ -1,17 +1,27 @@
function pp --description 'safely execute content from the clipboard'
# fish version of https://github.com/Aaronmsv/PastejackingProtection
-
- if not type -q xclip
- echo please install xclip
- return
- end
- set script (xclip -o)
- echo "$script" | cat -A
- echo -e "\nExecute? (y/N): "
- read execute
+ 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
- if test "$execute" = "y"
- eval $script
- 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