Created
July 13, 2016 18:28
-
-
Save ta0kira/46c08d0037bfcce737b4fe9495b63f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2016 Google Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# A short Python module to randomly color the text in your interactive session. | |
# | |
# 1. Save this as a file, e.g., "random_colors.py". | |
# 2. Start an interactive python session. | |
# 3. import random_colors | |
# 4. Watch the colors change as you type! | |
import threading | |
import time | |
import random | |
import sys | |
def RandomTerminalColors(): | |
while True: | |
time.sleep(random.gammavariate(1.0, 1.0)) | |
sys.__stderr__.write('\x1b[1;3%sm' % chr(random.randint(ord('0'), ord('7')))) | |
RandomTerminalColorsThread = threading.Thread(target=RandomTerminalColors) | |
RandomTerminalColorsThread.daemon = True | |
RandomTerminalColorsThread.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment