Useful Python3 and bash shell scripts for macOS/BSD and *NIX. Useful to me, at any rate. YMMV.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
scripnix
tests
.coveragerc
.gitignore
.travis.yml
LICENSE
Makefile
Manifest.in
README-prefix.md
README.md
README.rst
build-readme.py
bump-version.py
requirements-dev.txt
requirements-test.txt
requirements.txt
setup.cfg
setup.py
test-command

README.md

Scripnix

Useful Python3 and bash shell scripts for macOS/BSD and *NIX. Useful to me, at any rate. YMMV.

status buildstatus codecov pypiversion pyversions licence

Replaces the old Scripnix0 project which had grown crufty and was not macOS-friendly.

Motivation

Scripnix was born during my Linux server admin days when I wanted all of my aliases and scriplets to follow me from machine to machine. Packaging everything together made installing and keeping up-to-date that much easier. Writing it was also a bash scripting learning exercise, although I soon grew to loathe space-containing-filenames and all of the quoting that implied.

As I moved more to MacOS, the BSD version of most commands clashed with the GNU/Linux versions that Scripnix assumed. Still wanting those handy aliases and scriplets on MacOS, I resurrected Scripnix, but with many more of the commands written in Python, and with Homebrew-supplied GNU versions of my favourite utilities. The Python rewrite sidestepped much of the silly bash quoting and syntax, and made testing practical.

Licence

Licensed under the GNU General Public License, version 3. Refer to the attached LICENSE file or see http://www.gnu.org/licenses/ for details.

Change Log

The current version is 0.1.12. Scripnix is semver-ish in its versioning scheme.

Scripnix is currently an alpha release, so expect many many breaking changes. Once ready for prime time, the major version number will jump to 2 to reflect that this is actually the second incarnation of Scripnix.

Installation

Following installation using one of the methods below, you may also want to run the install-scripnix command as the root user to setup the system-wide configuration. Any other users that also wish to use Scripnix should also run that command.

The install-scripnix command will also suggest changes to your ~/.bashrc or ~/.profile files to persist Scripnix in your environment. It will also suggest changes to the /etc/sudoers file (vi visudo) so that the Scripnix commands can be run via sudo when necessary.

Homebrew (macOS)

On macOS, Homebrew will take care of installing any dependencies, including Python 3.

brew tap yukondude/tap
brew install scripnix
install-scripnix

PyPI (POSIX)

On *NIX, you will first need to install Python 3.3 (or higher) using your preferred method.

pip3 install scripnix
install-scripnix

Development Setup

  1. Install Scripnix, as above, so that all of its dependencies are available.
  2. Create a Python 3 virtualenv for Scripnix: mkvirtualenv --python=$(which python3) Scripnix
  3. Clone the Scripnix repo: git clone https://github.com/yukondude/Scripnix.git
  4. Install dependencies: pip install -r requirements.txt -r requirements-dev.txt -r requirements-test.txt
  5. Install the project in development mode: ./setup.py develop
  6. Run the unit tests to make sure everything is copacetic: ./setup.py test
  7. Pour a snifter of Martell XO and light up a Bolivar Belicoso.

Commands

The following command descriptions were generated by describe-scripnix on February 6, 2017.

backup-file

Usage: backup-file [OPTIONS] [FILE]...

  Backup the given file(s) by making a copy of each with an appended
  modification date (yyyymmdd). Append a number if the backup file name
  already exists. Remove any SUID or executable permissions from the backup
  file.

Options:
  -D, --dry-run  Show what would happen without actually doing it.
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.

command-for-pid

Usage: command-for-pid [OPTIONS] [PID]

  Return the command name for the given Process ID (PID). If a PID is not
  specified, use the current process.

Options:
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.

common-netmask

Usage: common-netmask [OPTIONS] [IPADDR]...

  Given any number of full or partial dotted-quad IPv4 addresses, display
  the netmask (and bit length) that matches all of the addresses.

Options:
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.

describe-scripnix

Usage: describe-scripnix [OPTIONS]

  Generate descriptions of all of the Scripnix commands in Markdown format,
  suitable for appending to the Scripnix project's README.md file.

Options:
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.

find-grep

Usage: find-grep [<directory>] <regexp>

  Search through the file contents in the specified directory (or the current
  directory if not given), and below, for lines that match the given regular
  expression.

gather-cron-jobs

Usage: gather-cron-jobs [OPTIONS]

  Gather all of the system and user crontab scheduled jobs and display them
  in a consolidated table (tab-delimited by default): minute (m), hour (h),
  day of the month (dom), month (mon), day of the week (dow), user, and
  command. Optionally, the results may be sorted (as well as possible) by
  the scheduled hour and minute.

  Must be run as the root user.

Options:
  -d, --delimiter TEXT  Column delimiter character(s).  [default: tab]
  -H, --no-header       Don't display the table header row.
  -r, --run-parts       Display commands in a run-parts target directory as if
                        they were individually scheduled.
  -s, --sort            Sort table (approximately) by scheduled time.
  -V, --version         Show version and exit.
  -h, --help            Show this message and exit.

hyphenate

Usage: hyphenate [OPTIONS] [TEXT]...

  Translate the given text argument(s) (or use the input lines from STDIN)
  into the equivalent, filesystem-safe, hyphenated versions.

Options:
  -d, --delimiter TEXT  Word delimiter character(s).  [default: -]
  -V, --version         Show version and exit.
  -h, --help            Show this message and exit.

install-scripnix

Usage: install-scripnix [OPTIONS]

  Install Scripnix for the current user. Global configuration settings (once
  installed by the root user) are stored under the /etc/scripnix/ directory.
  Per-user configuration settings, including for the root user, are stored
  under the ~/.scripnix/ directory and override the global settings. The
  installation can be re-run repeatedly, but will not overwrite existing
  configuration settings (however file and directory permissions will be
  reset).

Options:
  --yes          Confirm the action without prompting.
  -v, --verbose  Display the commands as they are being executed.
  -D, --dry-run  Show what would happen without actually doing it.
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.

is-remote-cnx

Usage: is-remote-cnx 

  Detects whether this terminal is a remote SSH connection. Exit code will be
  zero if it is.

locate-ll

Usage: locate-ll <regexp>

  Locate files matching the given regular expression and display matches in a
  a long list format. (Requires that [g]updatedb be run periodically to build
  the database.)

os-name

Usage: os-name [OPTIONS]

  Return the operating system platform name.

Options:
  -T, --no-translate  Do not translate the original operating system string to
                      its more familiar name.
  -V, --version       Show version and exit.
  -h, --help          Show this message and exit.

show-cron-jobs

Usage: show-cron-jobs 

  Gather all of the system and user crontab scheduled jobs and display them
  in a consolidated table, sorted approximately by the scheduled time.

top-level-pid

Usage: top-level-pid [OPTIONS] [PID]

  Return the top-level parent (below the init or launchd process) Process ID
  (PID) for the given PID. If a PID is not specified, use the current
  process.

Options:
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.

whereis-scripnix

Usage: whereis-scripnix [OPTIONS]

  Return the full, absolute path to the Scripnix package.

Options:
  -V, --version  Show version and exit.
  -h, --help     Show this message and exit.