-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathweb.fish
More file actions
146 lines (122 loc) · 6.68 KB
/
Copy pathweb.fish
File metadata and controls
146 lines (122 loc) · 6.68 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Calls to various CLI friendly web services
#
# Author: [Dmitry](http://dmi3.net) [Source](https://github.com/dmi3/fish)#
# * `myip` Shows external ip
alias myip='curl ifconfig.co'
# * `localip` Shows (local) internal ip
# alternative would be `ifdata -pa eth0` from moreutils
alias localip="ip -o route get to 1.1.1.1 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'"
# * `whereami` is like whoami but shows your external ip and geolocation
alias whereami='curl ifconfig.co/json'
function random-name --description "Random name for registration on random websites. How about Helen Lovick? Roger Rice?"
curl -s "https://randomuser.me/api/" | jq -r '.results[0].name.first + " " + .results[0].name.last'
end
function random-alias --description "Docker-like alias generator: `thirsty_mahavira`, `boring_heisenberg`. Don't know how to name file/project/branch/file? Use this!"
curl -s https://frightanic.com/goodies_content/docker-names.php | tee /dev/tty | xclip -sel clip; and echo -e "\ncopied to clipboard"
end
function random-email --description "Random email for registration on random websites. Generate random email in one of Mailinator subdomains and provide link to check it. Useful when <http://bugmenot.com/> is not available."
set domain (echo -e \
"notmailinator.com
veryrealemail.com
chammy.info
tradermail.info
mailinater.com
suremail.info
reconmail.com" | shuf -n1)
set name (curl -s "https://randomuser.me/api/" | jq -r '.results[0].name.first + .results[0].name.last')
set email $name@$domain
printf "$email" | tee /dev/tty | xclip -sel clip
echo -e "\ncopied to clipboard\nhttps://www.mailinator.com/v4/public/inboxes.jsp?to=$name"
end
function duckmails --description "Duck Mails! Woo-oo! Private Duck Address Generator"
if not test -f "$HOME/keys/duck"
echo "File at ~/keys/duck should contain token from dev tools on https://duckduckgo.com/email/"
return 1
end
curl -s -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.3" 'https://quack.duckduckgo.com/api/email/addresses' -X POST -H "authorization: Bearer "(cat ~/keys/duck) -H 'content-type: application/json' | jq -r '.address + "@duck.com"' | tr -d '\n' | xclip -sel clip
echo "Duck Mails! Woo-oo! (copied to clipboard):"
echo (xclip -sel clip -o)
end
function random-password --description "Generate random password" --argument-names 'length'
test -n "$length"; or set length 13
head /dev/urandom | tr -dc "[:alnum:]~!#\$%^&*-+=?./|" | head -c $length | tee /dev/tty | xclip -sel clip; and echo -e "\ncopied to clipboard"
end
function weather --description "Show weather"
resize -s $LINES 125
curl wttr.in/$argv
end
function xsh --description "Prepend this to command to explain its syntax i.e. `xsh iptables -vnL --line-numbers`"
w3m -o confirm_qq=false "http://explainshell.com/explain?cmd=$argv"
# replace w3m to any browser like chrome
end
function syn --description "Find synonyms for word"
test -e ~/git/stuff/keys/bighugelabs || echo "Get API key at https://words.bighugelabs.com/account/getkey and put in "(status --current-filename)
curl http://words.bighugelabs.com/api/2/(cat ~/git/stuff/keys/bighugelabs)/$argv/
end
function waitweb --description 'Wait until web resource is available. Useful when you are waiting for internet to get back, or Spring to start' --argument-names 'url'
set -q url || set url 'google.com'
printf "Waithing for the $url"
while not curl --output /dev/null --silent --head --fail "$url"
printf '.'
sleep 10
end
printf "\n$url is online!"
notify-send -u critical "$url is online!"
end
function uselessfact --description "Print random useless fact. Makes checking if internet is awailable little less boring"
curl -s https://uselessfacts.jsph.pl/api/v2/facts/random | jq .text
end
# * `xkcd` Print color-adjusted xkcd in your terminal! See <https://developer.run/40>
alias xkcd='curl -sL https://c.xkcd.com/random/comic/ | grep -Po "https:[^\"]*" | grep png | xargs curl -s | convert -negate -fuzz 10% -transparent black png: png:- | kitty +kitten icat'
# * `albumart` Show hi-res album art of currently playing song in Spotify
# - Requires [sp](https://gist.github.com/wandernauta/6800547)
alias albumart='sp metadata | grep -Po "(?<=url\|).*" | xargs curl -s | grep -Po "https:[^\"]*" | grep "i.scdn.co/image/" | head -1 | xargs curl -s | kitty +kitten icat'
function virustotal --description "Check file hash by virustotal.com"
test -e ~/git/stuff/keys/virustotal || echo "Get API key at https://www.virustotal.com/gui/my-apikey and put in "(status --current-filename)
curl -sL --request GET \
--url https://www.virustotal.com/api/v3/files/(sha256sum $argv | cut -f 1 -d " ") \
--header "x-apikey: "(cat ~/git/stuff/keys/virustotal) \
| jq ".data .attributes .last_analysis_stats, .data .attributes .tags, .data .attributes .total_votes"
end
function raindrop --description "Create raindrop at raindrop.io"
set -l raindrop_key ~/git/stuff/keys/raindrop
if not test -e $raindrop_key
echo "Create token at https://app.raindrop.io/settings/integrations and put in $raindrop_key"
return 1
end
set -l url $argv[1]
set -l token (cat $raindrop_key)
set -l parse_response (curl -s -G -H "Authorization: Bearer $token" --data-urlencode "url=$url" "https://api.raindrop.io/rest/v1/import/url/parse")
set -l title (echo $parse_response | jq -r '.item.title // empty')
set -l excerpt (echo $parse_response | jq -r '.item.excerpt // empty')
set -l cover (echo $parse_response | jq -r '.item.cover // empty')
set -l type (echo $parse_response | jq -r '.item.type // empty')
set -l tags_raw (echo $parse_response | jq -r '.item.meta.tags // [] | join(",")')
# Build JSON payload, only include non-empty fields
set -l payload '{ "link": "'$url'"'
if test -n "$title"; set payload $payload', "title": "'$title'"'; end
if test -n "$excerpt"; set payload $payload', "excerpt": "'$excerpt'"'; end
if test -n "$cover"; set payload $payload', "cover": "'$cover'"'; end
if test -n "$type"; set payload $payload', "type": "'$type'"'; end
if test -n "$tags_raw"
# convert comma list to JSON array
set -l IFS ','
set -l tags_arr
for t in (string split , -- $tags_raw)
if test -n "$t"
set tags_arr $tags_arr '"'$t'"'
end
end
if test (count $tags_arr) -gt 0
set payload $payload', "tags": ['(string join , $tags_arr)']'
end
end
set payload $payload' }'
set -l create_response (curl -s -X POST -H "Authorization: Bearer $token" -H "Content-Type: application/json" -d $payload "https://api.raindrop.io/rest/v1/raindrop")
if echo $create_response | jq -e '.result == true' >/dev/null 2>&1
echo Success
else
echo $create_response
return 1
end
end