Update dynamic terminal background script to persist index via a temp file and update background colours.

Update dynamic terminal background script to persist index via a temp file and update background colours.