initial commit uwu

This commit is contained in:
Agatha Lovelace 2020-11-29 17:30:29 +02:00
commit 6cfe8a3e2e
No known key found for this signature in database
GPG Key ID: 2DB18BA2E0A80BC3
4 changed files with 56 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
venv/

29
README.md Normal file
View File

@ -0,0 +1,29 @@
# Introducing... ls stories!
Have you wanted to see what your friends are up to in their terminals?
Well, wonder no more! I got distracted from important things again and now this exists!
![Screenshot of command output](https://sapphic.pw/8VR27)
## Installation
First, create a virtual environment and install the dependencies:
```sh
cd path/to/repo
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
Then, just put this in your `.bashrc`/`.zshrc`/`etc` file and replace the path:
```sh
function ls() {
# ~25% chance of seeing new stories
[ "$RANDOM" -lt 8191 ] && (cd path/to/repo/ ; ./stories.py )
command ls $@
}
```

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
names==0.3.0

25
stories.py Executable file
View File

@ -0,0 +1,25 @@
#!./venv/bin/python
import names
import random
import shutil
# pretty formatting!
titleformat = '\x1b[3;31m'
storyformat = '\x1b[1;0;41m'
reset = '\x1b[0m'
# get terminal size to make the output centered
termsize = shutil.get_terminal_size((80, 20))
# create a random amount of stories between 1 and 6
stories = f'{storyformat}[ name ]{reset} ' * random.randint(1, 6)
# replace each placeholder name with a random first or full name
for _ in range(stories.count('name')):
stories = stories.replace('name', random.choice(
[names.get_full_name(), names.get_first_name()]), 1
)
# output the unholy text
print(f'{titleformat}New stories:{reset}'.center(termsize.columns))
print(stories.center(termsize.columns) + '\n')