Skip to content
A collection of CLI scripts to automate repeated and mundane tasks.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.editorconfig
.flake8
.gitignore
README.md
creds
fx
movie
pyproject.lock
pyproject.toml
setup.cfg
weather

README.md

Utility Scripts

A collection of scripts to automate repeated and mundane tasks. Some of these could be set-up as aliases but this keeps everything organised in one repo.

Table of Contents

Script Usage

Set AWS Creds

Used to request session tokens as part of using AWS CLI when your AWS profile has MFA set-up.

creds <profile> <mfa-token>

Foreign Currency Exchange

fx
# and follow the prompts. Script is fairly basic at the moment so make sure to
# type currency abbreviations correctly

Git Fetch and Pull from Remote Current Branch

gfb

Git Fetch and Pull from Remote Master

# note, this switches branch to master
gfm

Git Log Graph Pretty

glogg

Git Prune Branches

# run from dir where you want to prune branches
prune [-d|-D]

Movie

movie <film title>

# example, single word film title
movie jaws

# example, multi-word film title
movie 'star wars'

Pyclean

# run from dir where you want to clean .pyo .pyc __pycache__
pyclean

Trash

# empties the Trash on MacOS
trash

Weather

# Usage: `weather CITYNAME` or just `weather` to use IP location.
weather <city>

Installation

Pre-requisites

  • Python 3
  • Poetry

(And for the AWS credentials script)

  • AWS CLI
  • AWS credentials file per this

Git clone and add to $PATH

  • Git clone the repo to a local directory.
  • Add the directory to path so all scripts can be called from any location.
    • in ~/.bashrc for the bash shell
    • in ~/.zshrc for the zsh shell
export PATH=$PATH:~/{code-directory}/util-scripts
  • Make the scripts executable
chmod u+x ./{script_name}

Python set-up

Create a virtualenv

virtualenv -p python3 env

Install Python dependencies using Poetry:

poetry install

AWS creds set-up

Follow AWS CLI docs to set it up and configure profiles. Profile information should be manually copied across into the .env file per the below.

Add an .env file

Convert the .env.template to an .env file and populate the details with AWS credentials. The list of profile prefixes must match the start of the profile info, per the template file.

Tests

To run tests:

# activate virtual env
source env/bin/activate

# run tests
pytest

# run tests with verbosity
pytest -vv

# run tests with code coverage
pytest --cov
You can’t perform that action at this time.