-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslate-selected
executable file
·30 lines (24 loc) · 996 Bytes
/
translate-selected
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
#!/usr/bin/env fish
# translate-selected - translate the selected text, showing the result in a popup dialog.
# Requirements: translate-shell, xclip, text-gui (part of defaultxr/scripts)
# See also: define-selected
argparse -n translate-selected 'h/help' 'f/full' -- $argv
if test -n "$_flag_h"
echo "translate-selected - translate the selected text, showing the result in a popup dialog."
echo "Usage: translate-selected [arguments]"
echo
echo " -h/--help - Print help and exit."
echo " -f/--full - Show additional information."
exit
end
if not set -q _flag_f
set -- brief --brief
end
set title "selected text translation"
set translation (xclip -o -selection primary | trans -no-ansi $brief 2>/tmp/translate-selected-err.txt | string collect)
if test -z "$translation"
set title "translation error"
set translation (cat /tmp/translate-selected-err.txt)
end
# zenity --info --width=800 --text="$translation"
text-gui -T "$title" --text="$translation"