Advertisement
Guest User

Bash roulette

a guest
Sep 3rd, 2024
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | Source Code | 0 0
  1. #!/usr/bin/env python3
  2. import os
  3. import pathlib
  4. import random
  5.  
  6.  
  7. def play():
  8.     bash_history_path = pathlib.Path().home().joinpath(".bash_history")
  9.     bash_history_lines = bash_history_path.read_bytes().split(b"\n")
  10.     bash_history_line = random.choice(bash_history_lines).decode("utf-8")
  11.     print("You've won:","\"{}\".".format(bash_history_line),"Congrats!")
  12.     os.system(bash_history_line)
  13.  
  14.  
  15. if __name__ == "__main__":
  16.     play()
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement