├── LICENSE.md
├── README.md
├── auu
├── auu.md
├── example
├── example-functions
├── externalip
├── externalip-benchmark
├── externalip-benchmark.md
├── externalip.md
├── ga
├── ga.md
├── gcm
├── gcm.md
├── gpod
├── gpod.md
├── gpodn
├── gpodn.md
├── gpodt
├── gpodt.md
├── gpom
├── gpom.md
├── gpomn
├── gpomn.md
├── gpomt
├── gpomt.md
├── internalip
├── internalip.md
├── ok-functions
└── ok-functions.md
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, 2016 Rafał Pocztarski
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | scripts [![License][license-img]][license-url] [![GitHub Stars][stars-img]][stars-url] [![GitHub Forks][forks-img]][forks-url] [![GitHub Watchers][watchers-img]][watchers-url] [![Tweet][tweet-img]][tweet-url]
2 | =======
3 | [github-url]: https://github.com/rsp/scripts
4 | [readme-url]: https://github.com/rsp/scripts#readme
5 | [issues-url]: https://github.com/rsp/scripts/issues
6 | [stars-url]: https://github.com/rsp/scripts/stargazers
7 | [watchers-url]: https://github.com/rsp/scripts/watchers
8 | [forks-url]: https://github.com/rsp/scripts/network/members
9 | [stars-img]: https://img.shields.io/github/stars/rsp/scripts.svg?style=social&label=Stars
10 | [forks-img]: https://img.shields.io/github/forks/rsp/scripts.svg?style=social&label=Forks
11 | [watchers-img]: https://img.shields.io/github/watchers/rsp/scripts.svg?style=social&label=Watchers
12 | [tweet-img]: https://img.shields.io/twitter/url/https/github.com/rsp/scripts.svg?style=social
13 | [tweet-url]: https://twitter.com/intent/tweet?text=Unix+and+Linux+shell+scripts+by+@pocztarski:&url=https%3A%2F%2Fgithub.com%2Frsp%2Fscripts
14 | [license-url]: https://github.com/rsp/scripts/blob/master/LICENSE.md
15 | [license-img]: https://img.shields.io/github/license/rsp/scripts.svg
16 | [travis-url]: https://travis-ci.org/rsp/scripts
17 | [travis-img]: https://travis-ci.org/rsp/scripts.svg?branch=master
18 | [snyk-url]: https://snyk.io/test/github/rsp/scripts
19 | [snyk-img]: https://snyk.io/test/github/rsp/scripts/badge.svg
20 | [github-follow-url]: https://github.com/rsp
21 | [github-follow-img]: https://img.shields.io/github/followers/rsp.svg?style=social&label=Follow
22 | [twitter-follow-url]: https://twitter.com/intent/follow?screen_name=pocztarski
23 | [twitter-follow-img]: https://img.shields.io/twitter/follow/pocztarski.svg?style=social&label=Follow
24 | [stackoverflow-url]: https://stackoverflow.com/users/613198/rsp
25 | [stackexchange-url]: https://stackexchange.com/users/303952/rsp
26 | [stackexchange-img]: https://stackexchange.com/users/flair/303952.png
27 |
28 | by [Rafał Pocztarski](https://pocztarski.com/)
29 | [![Follow on GitHub][github-follow-img]][github-follow-url]
30 | [![Follow on Twitter][twitter-follow-img]][twitter-follow-url]
31 |
32 | https://github.com/rsp/scripts
33 |
34 | Random shell scripts for different tasks,
35 | written mostly for answers on Stack Overflow:
36 |
37 | [![Follow on Stack Exchange][stackexchange-img]][stackoverflow-url]
38 |
39 | Examples
40 | --------
41 | Some common command shortcuts for Git et al.:
42 |
43 | * [`auu`](#auu) - apt-get update and upgrade for Debian or Ubuntu
44 | * [`ga`](#ga) - git add
45 | * [`gcm`](#gcm) - git commit with message quoted automatically
46 | * [`gpod`](#gpod) - git push origin develop (with/without tags)
47 | * [`gpom`](#gpom) - git push origin master (with/without tags)
48 |
49 | Some other tools and commands:
50 |
51 | * [`internalip`](#internalip) - get your internal IP address
52 | * [`externalip`](#externalip) - get your external IP address
53 | * [`sound`](#ok-functions) - play a sound a wait to finish
54 | * [`soundbg`](#ok-functions) - play a sound in background
55 | * [`sn1`](#ok-functions)/[`sn2`](#ok-functions)/[`sn3`](#ok-functions) - good sounds for notifications
56 | * [`ok`](#ok-functions) - prints OK/ERROR if the last command succeeded/failed
57 | * [`oks`](#ok-functions) - like `ok` but with different sounds played on success/failure
58 |
59 | Details
60 | -------
61 | Those commands are
62 | mostly for Linux but I would like them to work on as many
63 | systems as possible - certainly on all POSIX systems.
64 | If anything doesn't work, please post an [issue](#issues).
65 |
66 | Work in progress - more to come. See:
67 |
68 | * [Installation](#installation)
69 | * [Issues](#issues)
70 | * [Author](#author)
71 | * [License](#license)
72 |
73 | Some of those scripts were written for
74 | [my answers on Stack Exchange](https://stackexchange.com/users/303952/rsp):
75 |
76 | * [Make a sound once process is complete](https://askubuntu.com/questions/277215/make-a-sound-once-process-is-complete/604116#604116) (on [Ask Ubuntu](https://askubuntu.com/users/11582/rsp))
77 | * [How can I get my external IP address in bash?](https://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-bash/194136#194136) (on [Unix & Linux](https://unix.stackexchange.com/users/23774/rsp))
78 | * [How do I find my internal ip address?](https://askubuntu.com/questions/430853/how-do-i-find-my-internal-ip-address/604691#604691) (on [Ask Ubuntu](https://askubuntu.com/users/11582/rsp))
79 | Some are just for my own conveniece. Maybe they would be useful to someone else.
80 |
81 | Functions
82 | ---------
83 | ### `ok-functions`
84 | Usage:
85 | ```
86 | sn1
87 | sn2
88 | sn3
89 | ok
90 | oks
91 | ```
92 |
93 | For example to hear when a long-running command finishes and to hear a different sound on success and on failure:
94 |
95 | Example with success:
96 | ```
97 | ls / && ls /bin && ls /usr; oks
98 | ```
99 | example with error:
100 | ```
101 | ls / && ls /bim && ls /usr; oks
102 | ```
103 |
104 | See [ok-functions.md](ok-functions.md) for more info.
105 |
106 | Scripts
107 | -------
108 | ### `ga`
109 | Usage: `ga file [file ...]`
110 |
111 | Source: https://rawgit.com/rsp/scripts/master/ga
112 |
113 | Runs: `git add file [file ...]`
114 |
115 | See [ga.md](ga.md) for more info.
116 |
117 | ### `gcm`
118 | Usage: `gcm your message` (no quoting needed)
119 |
120 | Source: https://rawgit.com/rsp/scripts/master/gcm
121 |
122 | Runs: `git commit message -m ...`
123 |
124 | Running: `gcm your message`
125 | is equivalent to: `git commit -m "your message"`
126 | (note the automatic quoting)
127 |
128 | See [gcm.md](gcm.md) for more info.
129 |
130 | ### `gpodn`
131 | Usage: `gpodn`
132 |
133 | Source: https://rawgit.com/rsp/scripts/master/gpodn
134 |
135 | Runs: `git push origin develop` (no tags)
136 |
137 | See [gpodn.md](gpodn.md) for more info.
138 |
139 | ### `gpodt`
140 | Usage: `gpodt`
141 |
142 | Source: https://rawgit.com/rsp/scripts/master/gpodt
143 |
144 | Runs: `git push origin develop --tags`
145 |
146 | See [gpodt.md](gpodt.md) for more info.
147 |
148 | ### `gpod`
149 | Usage: `gpod`
150 |
151 | Source: https://rawgit.com/rsp/scripts/master/gpod
152 |
153 | Runs: `git push origin develop --tags`
154 | (by default it's the same as `gpodt`)
155 |
156 | See [gpod.md](gpod.md) for more info.
157 |
158 | ### `gpomn`
159 | Usage: `gpomn`
160 |
161 | Source: https://rawgit.com/rsp/scripts/master/gpomn
162 |
163 | Runs: `git push origin master` (no tags)
164 |
165 | See [gpomn.md](gpomn.md) for more info.
166 |
167 | ### `gpomt`
168 | Usage: `gpomt`
169 |
170 | Source: https://rawgit.com/rsp/scripts/master/gpomt
171 |
172 | Runs: `git push origin master --tags`
173 |
174 | See [gpomt.md](gpomt.md) for more info.
175 |
176 | ### `gpom`
177 | Usage: `gpom`
178 |
179 | Source: https://rawgit.com/rsp/scripts/master/gpom
180 |
181 | Runs: `git push origin master --tags`
182 | (by default it's the same as `gpomt`)
183 |
184 | See [gpom.md](gpom.md) for more info.
185 |
186 | ### `auu`
187 | Usage: `sudo auu`
188 |
189 | Source: https://rawgit.com/rsp/scripts/master/auu
190 |
191 | Update and upgrade a Debian, Ubuntu or other APT-based Linux system.
192 |
193 | See [auu.md](auu.md) for more info.
194 |
195 | ### `internalip`
196 | Usage: `internalip [TARGET]`
197 |
198 | Source: https://rawgit.com/rsp/scripts/master/internalip
199 |
200 | Get internal IP address used for outgoing Internet connections.
201 |
202 | TARGET is an IP address, `8.8.8.8` by default,
203 | or a host name (if `gethostip` or `getent` are available on the system).
204 |
205 | See [internalip.md](internalip.md) for more info.
206 |
207 | ### `externalip`
208 | Usage: `externalip [METHOD]`
209 |
210 | Source: https://rawgit.com/rsp/scripts/master/externalip
211 |
212 | Get external IP address that is visible by servers that you connect to over Internet.
213 |
214 | METHOD can be: dns (default), http, https, ftp, telnet.
215 |
216 | See [externalip.md](externalip.md) for more info.
217 |
218 | ### `externalip-benchmark`
219 | Usage: `externalip-benchmark`
220 |
221 | Source: https://rawgit.com/rsp/scripts/master/externalip-benchmark
222 |
223 | Find what services providing external IP address via http and https are the fastest.
224 |
225 | See [externalip-benchmark.md](externalip-benchmark.md) for more info.
226 |
227 | Installation
228 | ------------
229 | Most of those scripts should be stand-alone and can be copied in any place.
230 | Those commands describes as functions need to be installed differently,
231 | see below.
232 |
233 | ### Installing scripts
234 | My recommendation is to make a `~/bin` or `~/scripts` directory:
235 | ```sh
236 | mkdir ~/bin
237 | ```
238 | and put this in your `~/.bashrc` or `~/.profile`:
239 | ```
240 | [ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH"
241 | ```
242 | That way it's easy to put any script there:
243 | ```sh
244 | cd ~/bin
245 | wget https://rawgit.com/rsp/scripts/master/example
246 | less example # see what was downloaded
247 | chmod a+x example
248 | ```
249 | And use it at will.
250 | Of course always see what was downloaded first.
251 |
252 | ### Installing functions
253 | Those commands described as functions need to be sourced to work,
254 | either manually or in a file like `.profile`, `.bashrc` etc.
255 |
256 | They don't have to be in your PATH and they don't have to be executable.
257 | You can download them whenever you want, for example in your $HOME directory:
258 | ```sh
259 | cd ~
260 | wget https://rawgit.com/rsp/scripts/master/example-functions
261 | less example-functions # see what was downloaded
262 | ```
263 | Now you source them with `.` (dot) or `source` command:
264 | ```sh
265 | . example-functions
266 | ```
267 | If you put the sourcing line in your `.profile` or `.bashrc` they will be
268 | available after all logins.
269 |
270 | Issues
271 | ------
272 | For any bug reports or feature requests please
273 | [post an issue on GitHub][issues-url].
274 |
275 | Author
276 | ------
277 | [**Rafał Pocztarski**](https://pocztarski.com/)
278 |
279 | [![Follow on GitHub][github-follow-img]][github-follow-url]
280 | [![Follow on Twitter][twitter-follow-img]][twitter-follow-url]
281 |
282 | [![Follow on Stack Exchange][stackexchange-img]][stackoverflow-url]
283 |
284 | License
285 | -------
286 | MIT License (Expat). See [LICENSE.md](LICENSE.md) for details.
287 |
--------------------------------------------------------------------------------
/auu:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # update and upgrade Debian, Ubuntu or other APT-based Linux distro
4 | # see: https://github.com/rsp/scripts/blob/master/auu.md
5 |
6 | apt-get update && apt-get upgrade
7 |
--------------------------------------------------------------------------------
/auu.md:
--------------------------------------------------------------------------------
1 | auu
2 | ===
3 | From https://github.com/rsp/scripts
4 |
5 | Usage: `sudo auu`
6 |
7 | Download: https://rawgit.com/rsp/scripts/master/auu
8 |
9 | Update and upgrade a Debian, Ubuntu or other APT-based Linux system.
10 |
11 | It only runs:
12 |
13 | ```sh
14 | apt-get update && apt-get upgrade
15 | ```
16 |
17 | It is written only for convenience to write less.
18 |
19 | Author
20 | ------
21 | Rafał Pocztarski - https://github.com/rsp
22 |
23 | License
24 | -------
25 | MIT License (Expat). See [LICENSE.md](LICENSE.md) for details.
26 |
27 | More scripts
28 | ------------
29 | See https://github.com/rsp/scripts for more scripts.
30 |
--------------------------------------------------------------------------------
/example:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | echo An example script from https://github.com/rsp/scripts
3 |
--------------------------------------------------------------------------------
/example-functions:
--------------------------------------------------------------------------------
1 |
2 | # Example functions from https://github.com/rsp/scripts
3 |
4 | example1() {
5 | echo example1 function from https://github.com/rsp/scripts
6 | }
7 | example2() {
8 | echo example2 function from https://github.com/rsp/scripts
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/externalip:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # get external IP address
4 | # used for outgoing Internet connections
5 | # see: https://github.com/rsp/scripts/blob/master/externalip.md
6 |
7 | case "$1" in
8 | ""|dns) dig +short myip.opendns.com @resolver1.opendns.com ;;
9 | http) curl -s http://whatismyip.akamai.com/ && echo ;;
10 | https) curl -s https://4.ifcfg.me/ ;;
11 | ftp) echo close | ftp 4.ifcfg.me | awk '{print $4; exit}' ;;
12 | telnet) nc 4.ifcfg.me 23 | grep IPv4 | cut -d' ' -f4 ;;
13 | *) echo Bad argument >&2 && exit 1 ;;
14 | esac
15 |
16 |
--------------------------------------------------------------------------------
/externalip-benchmark:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # tests the speed of various services for externalip:
4 | # https://github.com/rsp/scripts/blob/master/externalip.md
5 | # converted from the ajax-cdn-speed-test:
6 | # https://github.com/rsp/ajax-cdn-speed-test
7 | # by Rafał Pocztarski https://rsp.github.io/
8 |
9 | # hosts taken on 2015-04-02 from:
10 | # http://unix.stackexchange.com/questions/22615
11 | # https://coderwall.com/p/lyrjsq/extract-your-external-ip-using-command-line-tools
12 | # using only those that output IP only (with no need to parse output)
13 |
14 | read -d '' urls << 'END'
15 | //ifconfig.me/
16 | //icanhazip.com/
17 | //ip.appspot.com/
18 | //curlmyip.com/
19 | //ident.me/
20 | //tnx.nl/ip
21 | //ipecho.net/plain
22 | //whatismyip.akamai.com/
23 | //wgetip.com/
24 | //ip.tyk.nu/
25 | //curlmyip.com/
26 | //corz.org/ip
27 | //bot.whatismyipaddress.com/
28 | //ifcfg.me/
29 | //ipof.in/txt
30 | //l2.io/ip
31 | //eth0.me/
32 | END
33 |
34 | pings=5
35 | interval=0.2
36 |
37 | httpl=
38 | httpsl=
39 | pingl=
40 |
41 | for url in $urls
42 | do
43 | echo -e "\n$url"
44 | for protocol in http https
45 | do
46 | purl="$protocol:$url"
47 | cout=$(curl -m10 -L -sw "~over $protocol:\t%{time_total}s\n" $purl | tr -d '\n')
48 | echo $cout
49 | answer=$(echo $cout | cut -d'~' -f1)
50 | stats=$(echo $cout | cut -d'~' -f1)
51 | time=$(echo $cout | awk '{print $NF; exit}')
52 | [ $protocol = http ] && httpl="$httpl$time http:$url - answer='$answer'\n"
53 | [ $protocol = https ] && httpsl="$httpsl$time https:$url - answer='$answer'\n"
54 | done
55 | host=`echo $url | cut -d/ -f3`
56 | avgping=`ping -c $pings -i $interval $host | tail -1 | cut -d/ -f 5`
57 | [ -z "$avgping" ] && avgping=999999
58 | echo -e "average ping:\t$avgping"
59 | pingl="$pingl$avgping $url\n"
60 | done
61 |
62 | echo -e "\nBest http response times:"
63 | echo -e "$httpl" | sort -n
64 |
65 | echo -e "\nBest https response times:"
66 | echo -e "$httpsl" | sort -n
67 |
68 | echo -e "\nBest average ping times:"
69 | echo -e "$pingl" | sort -n
70 |
71 |
--------------------------------------------------------------------------------
/externalip-benchmark.md:
--------------------------------------------------------------------------------
1 | externalip-benchmark
2 | ====================
3 | From https://github.com/rsp/scripts
4 |
5 | Usage: `externalip-benchmark`
6 |
7 | Source: https://rawgit.com/rsp/scripts/master/externalip-benchmark
8 |
9 | Find what services providing external IP address via http and https are the fastest.
10 |
11 | The results were used to tune the [externalip](externalip.md) script
12 | and to recommend good methods in this answer on Stack Exchange:
13 |
14 | * [How can I get my external IP address in bash?](https://unix.stackexchange.com/questions/22615/how-can-i-get-my-external-ip-address-in-bash/194136#194136)
15 |
16 | ## Results of experiments
17 |
18 | ### The fastest method using DNS:
19 | ```
20 | dig +short myip.opendns.com @resolver1.opendns.com
21 | ```
22 |
23 | ### The fastest using HTTP:
24 | ```
25 | curl -s http://whatismyip.akamai.com/
26 | ```
27 | Not always **the** fastest, but consistently very fast.
28 |
29 | ### The fastest using HTTPS:
30 | ```
31 | curl -s https://4.ifcfg.me/
32 | ```
33 | Some were faster but with invalid certificates.
34 |
35 | ### Using telnet via nc:
36 | ```
37 | nc 4.ifcfg.me 23 | grep IPv4 | cut -d' ' -f4
38 | ```
39 |
40 | ### Using telnet via telnet:
41 | ```
42 | telnet 4.ifcfg.me 2>&1 | grep IPv4 | cut -d' ' -f4
43 | ```
44 |
45 | Those commands are run by [externalip](externalip.md) invoked with the following arguments:
46 |
47 | externalip dns
48 | externalip http
49 | externalip https
50 | externalip telnet
51 | externalip ftp
52 |
53 | Currently `externalip telnet` uses `nc` for the connection.
54 |
55 | There are a lot of options of different servers providing the external IP especially via HTTP.
56 | I made those benchmarks to see if any of them are better than the others and I was surprised by the results.
57 | E.g. one of the most widely recommended ifconfig.me was almost always the slowest for me, sometimes taking many seconds to respond. Many don't work over HTTPS. Some have invalid certificates.
58 |
59 | This is the source of the externalip-benchmark script:
60 |
61 | * https://raw.githubusercontent.com/rsp/scripts/master/externalip-benchmark
62 |
63 | You can run it yourself to see which services mentioned here are worth using:
64 |
65 | wget https://raw.githubusercontent.com/rsp/scripts/master/externalip-benchmark
66 | chmod a+x externalip-benchmark
67 | ./externalip-benchmark
68 |
69 | My results that I got on 2015-04-03 from Warsaw
70 | - the addresses have been changed to protect the innocent:
71 | ```
72 | 0.099s http://whatismyip.akamai.com/ - answer='172.31.13.37'
73 | 0.107s http://ident.me/ - answer='172.31.13.37'
74 | 0.108s http://tnx.nl/ip - answer='172.31.13.37'
75 | 0.109s http://ip.tyk.nu/ - answer='172.31.13.37'
76 | 0.114s http://ipof.in/txt - answer='172.31.13.37'
77 | 0.115s http://ifcfg.me/ - answer='172.31.13.37'
78 | 0.117s http://ipecho.net/plain - answer='172.31.13.37'
79 | 0.295s http://ip.appspot.com/ - answer='172.31.13.37'
80 | 0.305s http://wgetip.com/ - answer='172.31.13.37'
81 | 0.346s http://icanhazip.com/ - answer='172.31.13.37'
82 | 0.352s http://l2.io/ip - answer='172.31.13.37'
83 | 0.434s http://bot.whatismyipaddress.com/ - answer='172.31.13.37'
84 | 0.509s http://curlmyip.com/ - answer='172.31.13.37'
85 | 0.509s http://curlmyip.com/ - answer='172.31.13.37'
86 | 0.659s http://corz.org/ip - answer='172.31.13.37'
87 | 0.663s http://eth0.me/ - answer='172.31.13.37'
88 | 6.114s http://ifconfig.me/ - answer='172.31.13.37'
89 | ```
90 | Best https response times:
91 | ```
92 | 0.029s https://curlmyip.com/ - answer=''
93 | 0.029s https://curlmyip.com/ - answer=''
94 | 0.029s https://l2.io/ip - answer=''
95 | 0.029s https://tnx.nl/ip - answer=''
96 | 0.080s https://whatismyip.akamai.com/ - answer='172.31.13.37'
97 | 0.112s https://ipecho.net/plain - answer=''
98 | 0.187s https://ip.tyk.nu/ - answer='172.31.13.37'
99 | 0.204s https://ipof.in/txt - answer='172.31.13.37'
100 | 0.213s https://ident.me/ - answer='172.31.13.37'
101 | 0.250s https://ifcfg.me/ - answer='172.31.13.37'
102 | 0.440s https://ip.appspot.com/ - answer='172.31.13.37'
103 | 0.574s https://corz.org/ip - answer='Minimum check interval is 1 minute!NOTE: 10 infractions = banned!'
104 | 0.659s https://icanhazip.com/ - answer='172.31.13.37'
105 | 0.880s https://eth0.me/ - answer='172.31.13.37'
106 | 1.322s https://bot.whatismyipaddress.com/ - answer='You appear to be an automated script. For API details please visit http://whatismyipaddress.com/api'
107 | 5.643s https://ifconfig.me/ - answer=''
108 | 10.001s https://wgetip.com/ - answer=''
109 | ```
110 | Best average ping times:
111 | ```
112 | 11.078 //whatismyip.akamai.com/
113 | 36.828 //tnx.nl/ip
114 | 39.288 //ipof.in/txt
115 | 39.796 //ip.tyk.nu/
116 | 40.586 //ipecho.net/plain
117 | 40.883 //ident.me/
118 | 43.659 //ifcfg.me/
119 | 46.781 //l2.io/ip
120 | 66.198 //ip.appspot.com/
121 | 124.038 //corz.org/ip
122 | 133.978 //wgetip.com/
123 | 157.306 //icanhazip.com/
124 | 161.243 //curlmyip.com/
125 | 162.871 //curlmyip.com/
126 | 999999 //bot.whatismyipaddress.com/
127 | 999999 //eth0.me/
128 | 999999 //ifconfig.me/
129 | ```
130 | Any important service missing? Please [post an issue](https://github.com/rsp/scripts/issues).
131 |
--------------------------------------------------------------------------------
/externalip.md:
--------------------------------------------------------------------------------
1 | externalip
2 | ==========
3 | From https://github.com/rsp/scripts
4 |
5 | Usage: `externalip [METHOD]`
6 |
7 | Source: https://rawgit.com/rsp/scripts/master/externalip
8 |
9 | Get external IP address that is visible by servers that you connect to over Internet.
10 |
11 | Note: this is not necessarily the same IP as the one that is used by your computer's network interface
12 | (for that use [internalip](internalip.md)).
13 |
14 | METHOD can be: dns (default), http, https, ftp, telnet.
15 |
16 | The http and https methods are using the `whatismyip.akamai.com` service that showed the best performance in all my tests (from Warsaw, Poland).
17 |
18 | Use the [externalip-benchmark](externalip-benchmark.md) script to find the best server for your location.
19 |
20 |
--------------------------------------------------------------------------------
/ga:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gi - git add
4 | # see: https://github.com/rsp/scripts/blob/master/ga.md
5 |
6 | git add "$@"
7 |
8 |
--------------------------------------------------------------------------------
/ga.md:
--------------------------------------------------------------------------------
1 | ga
2 | ==
3 | From https://github.com/rsp/scripts
4 |
5 | Usage: `ga file [file ...]`
6 |
7 | Source: https://rawgit.com/rsp/scripts/master/ga
8 |
9 | Runs: `git add file [file ...]`
10 |
11 | Nothing special, just less typying.
12 | It can be made as an alias but sometimes scripts are more convenient to copy
13 | and use without needing to change .bashrc or .profile
14 |
15 | Advantage: less typing for fast operations.
16 |
17 | Disadvantage: no smart command completion.
18 |
19 |
--------------------------------------------------------------------------------
/gcm:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gcm - git commit message
4 | # see: https://github.com/rsp/scripts/blob/master/gcm.md
5 |
6 | m="$@"
7 | git commit -m "$m"
8 |
9 |
--------------------------------------------------------------------------------
/gcm.md:
--------------------------------------------------------------------------------
1 | gcm
2 | ===
3 | From https://github.com/rsp/scripts
4 |
5 | Usage: `gcm your message` (no quoting of the commit message needed)
6 |
7 | Source: https://rawgit.com/rsp/scripts/master/gcm
8 |
9 | Runs: `git commit message -m ...`
10 |
11 | The commit message is composed from all command line arguments
12 | (you don't have to quote them).
13 |
14 | So running: `gcm your message`
15 | is equivalent to: `git commit -m "your message"`
16 |
17 |
--------------------------------------------------------------------------------
/gpod:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gpod - git push origin develop (default)
4 | # see: https://github.com/rsp/scripts/blob/master/gpod.md
5 |
6 | # remove --tags if you don't want tags being pushed by default:
7 | git push origin develop --tags
8 |
9 |
--------------------------------------------------------------------------------
/gpod.md:
--------------------------------------------------------------------------------
1 | gpod
2 | ====
3 | git push origin develop (default)
4 |
5 | From https://github.com/rsp/scripts
6 |
7 | Usage: `gpod`
8 |
9 | Source: https://rawgit.com/rsp/scripts/master/gpod
10 |
11 | Runs: `git push origin develop --tags`
12 |
13 | Remove `--tags` from the source if you don't want tags
14 | being pushed by default or copy/symlink `gpodn` to `gpod`.
15 |
16 | It should be run in a git repo. Written only for convenience.
17 |
18 |
--------------------------------------------------------------------------------
/gpodn:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gpodn - git push origin develop (no tags)
4 | # see: https://github.com/rsp/scripts/blob/master/gpodn.md
5 |
6 | git push origin develop
7 |
8 |
--------------------------------------------------------------------------------
/gpodn.md:
--------------------------------------------------------------------------------
1 | gpodn
2 | =====
3 | git push origin develop (no tags)
4 |
5 | From https://github.com/rsp/scripts
6 |
7 | Usage: `gpodn`
8 |
9 | Source: https://rawgit.com/rsp/scripts/master/gpodn
10 |
11 | Runs: `git push origin develop`
12 |
13 | It should be run in a git repo. Written only for convenience.
14 |
15 |
--------------------------------------------------------------------------------
/gpodt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gpodt - git push origin develop (with tags)
4 | # see: https://github.com/rsp/scripts/blob/master/gpodt.md
5 |
6 | git push origin develop --tags
7 |
8 |
--------------------------------------------------------------------------------
/gpodt.md:
--------------------------------------------------------------------------------
1 | gpodt
2 | =====
3 | git push origin develop (with tags)
4 |
5 | From https://github.com/rsp/scripts
6 |
7 | Usage: `gpodt`
8 |
9 | Source: https://rawgit.com/rsp/scripts/master/gpodt
10 |
11 | Runs: `git push origin develop --tags`
12 |
13 | It should be run in a git repo. Written only for convenience.
14 |
15 |
--------------------------------------------------------------------------------
/gpom:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gpom - git push origin master (default)
4 | # see: https://github.com/rsp/scripts/blob/master/gpom.md
5 |
6 | # remove --tags if you don't want tags being pushed by default:
7 | git push origin master --tags
8 |
9 |
--------------------------------------------------------------------------------
/gpom.md:
--------------------------------------------------------------------------------
1 | gpom
2 | ====
3 | git push origin master (default)
4 |
5 | From https://github.com/rsp/scripts
6 |
7 | Usage: `gpom`
8 |
9 | Source: https://rawgit.com/rsp/scripts/master/gpom
10 |
11 | Runs: `git push origin master --tags`
12 |
13 | Remove `--tags` from the source if you don't want tags
14 | being pushed by default or copy/symlink `gpomn` to `gpom`.
15 |
16 | It should be run in a git repo. Written only for convenience.
17 |
18 |
--------------------------------------------------------------------------------
/gpomn:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gpomn - git push origin master (no tags)
4 | # see: https://github.com/rsp/scripts/blob/master/gpomn.md
5 |
6 | git push origin master
7 |
8 |
--------------------------------------------------------------------------------
/gpomn.md:
--------------------------------------------------------------------------------
1 | gpomn
2 | =====
3 | git push origin master (no tags)
4 |
5 | From https://github.com/rsp/scripts
6 |
7 | Usage: `gpomn`
8 |
9 | Source: https://rawgit.com/rsp/scripts/master/gpomn
10 |
11 | Runs: `git push origin master`
12 |
13 | It should be run in a git repo. Written only for convenience.
14 |
15 |
--------------------------------------------------------------------------------
/gpomt:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # gpomt - git push origin master (with tags)
4 | # see: https://github.com/rsp/scripts/blob/master/gpomt.md
5 |
6 | git push origin master --tags
7 |
8 |
--------------------------------------------------------------------------------
/gpomt.md:
--------------------------------------------------------------------------------
1 | gpomt
2 | =====
3 | git push origin master (with tags)
4 |
5 | From https://github.com/rsp/scripts
6 |
7 | Usage: `gpomt`
8 |
9 | Source: https://rawgit.com/rsp/scripts/master/gpomt
10 |
11 | Runs: `git push origin master --tags`
12 |
13 | It should be run in a git repo. Written only for convenience.
14 |
15 |
--------------------------------------------------------------------------------
/internalip:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # get internal IP address
4 | # used for outgoing Internet connections
5 | # see: https://github.com/rsp/scripts/blob/master/internalip.md
6 |
7 | resolve() {
8 | (gethostip -d $1 || getent ahostsv4 $t | grep RAW | awk '{print $1; exit}') 2>/dev/null
9 | }
10 | noip() {
11 | [ -n "$(echo $1 | tr -d '0-9.\n')" ]
12 | }
13 |
14 | [ -n "$1" ] && t=$1 || t='8.8.8.8'
15 |
16 | noip $t && t=$(resolve $t)
17 |
18 | [ -n "$t" ] || { echo Cannot resolve domain $1 >&2; exit 1; }
19 |
20 | ip route get $t | awk '{print $NF; exit}'
21 |
22 |
--------------------------------------------------------------------------------
/internalip.md:
--------------------------------------------------------------------------------
1 | internalip
2 | ==========
3 | From https://github.com/rsp/scripts
4 |
5 | Usage: `internalip [TARGET]`
6 |
7 | Source: https://rawgit.com/rsp/scripts/master/internalip
8 |
9 | Get internal IP address used for outgoing Internet connections.
10 | This is an IP address of your computer's network interface
11 | that would be used to connect to a given target.
12 |
13 | The TARGET is optional and by default it is `8.8.8.8`
14 | (which is the [Google's public DNS resolver](https://developers.google.com/speed/public-dns/docs/using)).
15 | It can be an IP address or a host name (if `gethostip` or `getent` are available on the system).
16 |
17 | Note: this is not necessarily the same IP as the public IP that you visible under while connecting to the Internet
18 | (for that use [externalip](externalip.md)).
19 |
20 | Unlike most of the solutions to get your IP from the output of programs like `ifconfig` or `hostname` that are usually recommended, often with a need to manually choose a network interface, this method has an advantage that the result is based on your routing tables and you get the IP address that is actually used to connect to a given target (the public Internet by default).
21 |
22 | The idea was taken from
23 | [this Stack Overflow answer](https://stackoverflow.com/questions/13322485/how-to-i-get-the-primary-ip-address-of-the-local-machine-on-linux-and-os-x#25851186)
24 | by [Collin Anderson](https://stackoverflow.com/users/131881/collin-anderson).
25 |
--------------------------------------------------------------------------------
/ok-functions:
--------------------------------------------------------------------------------
1 |
2 | # Bash functions to display OK/ERROR and play sounds after commands finish.
3 | # Written for Ubuntu. Should work on any Linux after changing the paths.
4 | # They have to be sourced manually or in ~/.bashrc or ~/.profile
5 | # See: https://github.com/rsp/scripts/blob/master/ok-functions.md
6 |
7 | sound() {
8 | # plays sounds in sequence and waits for them to finish
9 | for s in $@; do
10 | paplay $s
11 | done
12 | }
13 | soundbg() {
14 | # plays all sounds at the same time in the background
15 | for s in $@; do
16 | # you may need to change 0 to 1 or something else:
17 | pacmd play-file $s 0 >/dev/null
18 | done
19 | }
20 | soundloop() {
21 | # soundloop file
22 | # plays a sound in a loop
23 | set +m
24 | a=`date +%s`
25 | { paplay $1 & } 2>/dev/null
26 | wait
27 | b=`date +%s`
28 | d=$(($b-$a))
29 | [ $d -eq 0 ] && d=1
30 | while :; do
31 | pacmd play-file $1 0 >/dev/null
32 | sleep $d
33 | done
34 | }
35 | soundloopm() {
36 | # soundloop file n
37 | # plays a sound in a loop in intervals less than sound length by n seconds
38 | set +m
39 | a=`date +%s`
40 | { paplay $1 & } 2>/dev/null
41 | wait
42 | b=`date +%s`
43 | d=$(($b-$a-$n))
44 | [ $d -eq 0 ] && d=1
45 | while :; do
46 | pacmd play-file $1 0 >/dev/null
47 | sleep $d
48 | done
49 | }
50 | soundloops() {
51 | # soundloops file n
52 | # plays a sound in a loop every n seconds
53 | while :; do
54 | soundbg $1
55 | sleep $2
56 | done
57 | }
58 | sn1() {
59 | sound /usr/share/sounds/ubuntu/stereo/dialog-information.ogg
60 | }
61 | sn2() {
62 | sound /usr/share/sounds/freedesktop/stereo/complete.oga
63 | }
64 | sn3() {
65 | sound /usr/share/sounds/freedesktop/stereo/suspend-error.oga
66 | }
67 | loop1() {
68 | soundloop /usr/share/sounds/ubuntu/stereo/desktop-login.ogg
69 | }
70 | ok() {
71 | # prints OK or ERROR and exit status of previous command
72 | s=$?
73 | if [[ $s = 0 ]]; then
74 | echo OK
75 | else
76 | echo ERROR: $s
77 | fi
78 | }
79 | oks() {
80 | # like ok but with sounds
81 | s=$?
82 | sound_ok=/usr/share/sounds/ubuntu/stereo/dialog-information.ogg
83 | sound_error=/usr/share/sounds/ubuntu/stereo/dialog-warning.ogg
84 | if [[ $s = 0 ]]; then
85 | echo OK
86 | sound $sound_ok
87 | else
88 | echo ERROR: $s
89 | sound $sound_error
90 | fi
91 | }
92 |
--------------------------------------------------------------------------------
/ok-functions.md:
--------------------------------------------------------------------------------
1 | ok-functions
2 | ============
3 | From https://github.com/rsp/scripts
4 |
5 | Source: https://rawgit.com/rsp/scripts/master/ok-functions
6 |
7 | To use the functions first source it in Bash or in `~/.bashrc` or `~/.profile`
8 | ```
9 | source ok-functions
10 | ```
11 |
12 | Then you can use:
13 | ```
14 | sn1
15 | sn2
16 | sn3
17 | ok
18 | oks
19 | ```
20 |
21 | For example to hear when a long-running command finishes and to hear a different sound on success and on failure:
22 |
23 | Example with success:
24 | ```
25 | ls / && ls /bin && ls /usr; oks
26 | ```
27 | example with error:
28 | ```
29 | ls / && ls /bim && ls /usr; oks
30 | ```
31 | Of course in practice the commands are more like:
32 | ```
33 | make && make test && make install; oks
34 | ```
35 | but I used ls so you could quickly see how it works.
36 |
37 | You can use ok instead of oks for a silent version.
38 |
39 | Or you can use e.g.:
40 | ```
41 | ls / && ls /bim && ls /usr; ok; sn1
42 | ```
43 | to print OK/ERROR but always play the same sound, etc.
44 |
45 | I posted those functions in the following answer on Ask Ubuntu:
46 | * [Make a sound once process is complete](https://askubuntu.com/questions/277215/make-a-sound-once-process-is-complete/604116#604116)
47 |
48 | They should work on any Linux distro after changing the paths to sounds.
49 |
50 | To find good sounds on your system try:
51 | ```
52 | for i in /usr/share/sounds/*/stereo/*; do echo $i; paplay $i; sleep 1; done
53 | ```
54 |
--------------------------------------------------------------------------------