-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtermux-url-opener
56 lines (55 loc) · 1.33 KB
/
termux-url-opener
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/data/data/com.termux/files/usr/bin/bash
cd ~/downloads
TMPFILE=dialog.tmp
function a {
if which "$1"
then
M[${#M[*]}]="${3:-$1}"
M[${#M[*]}]="${2:-$1}"
fi
}
a w3m 'w3m pager/browser'
if [[ $0 =~ -file-editor$ ]]; then
T=file
TN=name
a sensible-editor
a nano Nano
a ne 'The Nice Editor'
a mcedit 'Midnight Commander editor'
a vim 'Vi iMproved'
a vi 'Viewer/Editor'
a sensible-pager
a more 'more viewer'
a less 'less viewer'
a proj 'add to project' 'proj file ""'
a termux-share 'edit in app' 'termux-share -a edit'
a termux-share 'send to app' 'termux-share -a send'
a termux-share 'view in app'
elif [[ $0 =~ -url-opener$ ]]; then
T=url
a sensible-browser
a elinks
a lynx
a proj bookmark 'proj url ""'
if [[ $1 =~ ^(ht|f)tp: ]] || ! [[ "$(wget 2>&1)" =~ ^BusyBox ]]
then
a wget 'download with wget'
fi
#a curl 'download with curl' 'curl ?'
a termux-open-url 'view in app'
else
T=unknown
fi
a termux-clipboard-set "copy $T$TN to clipboard"
a termux-share "share $T$TN as text" 'termux-share -a send <<<'
a termux-open 'view in app' 'termux-open --chooser'
a termux-open 'send to app' 'termux-open --send --chooser'
dialog --title "Select Action" --menu "What to do with $T $1" 0 0 0 "${M[@]}" echo test 2>$TMPFILE
if [ $? = 0 ]
then eval "$(< $TMPFILE) '$1'"
elif [ -s $TMPFILE ]
then
echo Dialog error:
cat $TMPFILE
fi
rm $TMPFILE