Skip to content

Latest commit

 

History

History
286 lines (212 loc) · 8.82 KB

README.md

File metadata and controls

286 lines (212 loc) · 8.82 KB

scripts License GitHub Stars GitHub Forks GitHub Watchers Tweet

by Rafał Pocztarski Follow on GitHub Follow on Twitter

https://github.com/rsp/scripts

Random shell scripts for different tasks, written mostly for answers on Stack Overflow:
Follow on Stack Exchange

Examples

Some common command shortcuts for Git et al.:

  • auu - apt-get update and upgrade for Debian or Ubuntu
  • ga - git add
  • gcm - git commit with message quoted automatically
  • gpod - git push origin develop (with/without tags)
  • gpom - git push origin master (with/without tags)

Some other tools and commands:

  • internalip - get your internal IP address
  • externalip - get your external IP address
  • sound - play a sound a wait to finish
  • soundbg - play a sound in background
  • sn1/sn2/sn3 - good sounds for notifications
  • ok - prints OK/ERROR if the last command succeeded/failed
  • oks - like ok but with different sounds played on success/failure

Details

Those commands are mostly for Linux but I would like them to work on as many systems as possible - certainly on all POSIX systems. If anything doesn't work, please post an issue.

Work in progress - more to come. See:

Some of those scripts were written for my answers on Stack Exchange:

Functions

ok-functions

Usage:

sn1
sn2
sn3
ok
oks

For example to hear when a long-running command finishes and to hear a different sound on success and on failure:

Example with success:

ls / && ls /bin && ls /usr; oks

example with error:

ls / && ls /bim && ls /usr; oks

See ok-functions.md for more info.

Scripts

ga

Usage: ga file [file ...]

Source: https://rawgit.com/rsp/scripts/master/ga

Runs: git add file [file ...]

See ga.md for more info.

gcm

Usage: gcm your message (no quoting needed)

Source: https://rawgit.com/rsp/scripts/master/gcm

Runs: git commit message -m ...

Running: gcm your message is equivalent to: git commit -m "your message" (note the automatic quoting)

See gcm.md for more info.

gpodn

Usage: gpodn

Source: https://rawgit.com/rsp/scripts/master/gpodn

Runs: git push origin develop (no tags)

See gpodn.md for more info.

gpodt

Usage: gpodt

Source: https://rawgit.com/rsp/scripts/master/gpodt

Runs: git push origin develop --tags

See gpodt.md for more info.

gpod

Usage: gpod

Source: https://rawgit.com/rsp/scripts/master/gpod

Runs: git push origin develop --tags (by default it's the same as gpodt)

See gpod.md for more info.

gpomn

Usage: gpomn

Source: https://rawgit.com/rsp/scripts/master/gpomn

Runs: git push origin master (no tags)

See gpomn.md for more info.

gpomt

Usage: gpomt

Source: https://rawgit.com/rsp/scripts/master/gpomt

Runs: git push origin master --tags

See gpomt.md for more info.

gpom

Usage: gpom

Source: https://rawgit.com/rsp/scripts/master/gpom

Runs: git push origin master --tags (by default it's the same as gpomt)

See gpom.md for more info.

auu

Usage: sudo auu

Source: https://rawgit.com/rsp/scripts/master/auu

Update and upgrade a Debian, Ubuntu or other APT-based Linux system.

See auu.md for more info.

internalip

Usage: internalip [TARGET]

Source: https://rawgit.com/rsp/scripts/master/internalip

Get internal IP address used for outgoing Internet connections.

TARGET is an IP address, 8.8.8.8 by default, or a host name (if gethostip or getent are available on the system).

See internalip.md for more info.

externalip

Usage: externalip [METHOD]

Source: https://rawgit.com/rsp/scripts/master/externalip

Get external IP address that is visible by servers that you connect to over Internet.

METHOD can be: dns (default), http, https, ftp, telnet.

See externalip.md for more info.

externalip-benchmark

Usage: externalip-benchmark

Source: https://rawgit.com/rsp/scripts/master/externalip-benchmark

Find what services providing external IP address via http and https are the fastest.

See externalip-benchmark.md for more info.

Installation

Most of those scripts should be stand-alone and can be copied in any place. Those commands describes as functions need to be installed differently, see below.

Installing scripts

My recommendation is to make a ~/bin or ~/scripts directory:

mkdir ~/bin

and put this in your ~/.bashrc or ~/.profile:

[ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH"

That way it's easy to put any script there:

cd ~/bin
wget https://rawgit.com/rsp/scripts/master/example
less example # see what was downloaded
chmod a+x example

And use it at will. Of course always see what was downloaded first.

Installing functions

Those commands described as functions need to be sourced to work, either manually or in a file like .profile, .bashrc etc.

They don't have to be in your PATH and they don't have to be executable. You can download them whenever you want, for example in your $HOME directory:

cd ~
wget https://rawgit.com/rsp/scripts/master/example-functions
less example-functions # see what was downloaded

Now you source them with . (dot) or source command:

. example-functions

If you put the sourcing line in your .profile or .bashrc they will be available after all logins.

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange

License

MIT License (Expat). See LICENSE.md for details.