-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtel-share
executable file
·59 lines (55 loc) · 1.84 KB
/
tel-share
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
56
57
58
#!/usr/bin/env bash
#cd ~/../
FZF_DEFAULT_OPTS="
--info=inline
--multi
--preview-window=up:60%:follow:sharp
--preview '([[ -f {} ]] && (bat --style=numbers --color=always {} || cat {})) || ([[ -d {} ]] && (tree -C {} | less)) || echo {} 2> /dev/null | head -200'
--prompt='∼ ' --pointer='>' --marker='✓'
--bind '?:toggle-preview'
--bind 'ctrl-a:select-all'
--bind 'ctrl-y:execute-silent(echo {+} | pbcopy)'
"
show_help(){
printf "%s\n"\
"tel-share [OPTIONS] [FILE]"\
"__________________________"\
"USAGE"\
"tel-share = find a file to share"\
"tel-share example.jpg = share example.jpg"\
"echo Sent from tel | tel-share = share output of echo command"\
"fortune | tel-share -l = share output of fortune and display output of piped command"\
"tel-share -h = display this help message"
}
if [ ! -t 0 ] ; then # Script is getting input from pipe or file - non-interactivethen
while read line
do
lines="$lines $line"
done
am start -a android.intent.action.SEND -t text/plain -e android.intent.extra.TEXT "$lines" > /dev/null 2>&1
if [ "$1" == "-l" ] ; then
printf "\e[33;5;2m Sharing\e[m%s: piped data\n$lines"
else
printf "\e[33;5;2m Sharing\e[m%s: piped data"
fi
exit 0
else
if [ -z $1 ] ; then
selected_file=$(fzf --color=16 --prompt=" Share: ")
else
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
show_help
exit 0
fi
file_search="$@"
selected_file=$(fd --absolute-path --exclude .git --hidden --follow | fzf -e --color=16 --query="$file_search" --prompt=" File to share: " --select-1)
fi
if [ -z $selected_file ] ; then
# echo 'No file chosen - Exiting...'
exit 1
else
curr_dir=$(pwd)
printf "\e[33;5;2m Sharing\e[m%s file: $selected_file"
termux-share -a send "$selected_file" || echo "Couldn't share $selected_file"
fi
fi