-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmpc
executable file
·42 lines (34 loc) · 1.02 KB
/
tmpc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/env python3
from sys import argv
from os import listdir, makedirs, system, path
from configparser import ConfigParser
from random import randint, choice
src = __file__.rsplit("/", 1)[0]
config = ConfigParser(
{
"editor": "helix",
"terminal": "foot"
},
default_section="CONFIG"
)
config.read("~/.config/tmpc/config.ini")
NAMES = ["john", "main", "home", "thing", "test", "bob", "gayming", "main",
"test", "temp", "thingy", "uwu", "file"]
templates = listdir(f"{src}/templates")
for i,v in enumerate(templates):
print(f"{i}. {v}")
n = "a"
while not(n.isdigit() or n.startswith(".")):
n = input(f"[0-{len(templates)-1}] | '.'<extension> :")
fn = randint(0, 9999)
folder = f"{src}/projs/{fn:04}"
while path.exists(folder):
fn += 1
folder = f"{src}/projs/{fn:04}"
makedirs(folder)
if n.isdigit():
system(f"cp -r {src}/templates/{templates[int(n)]} {folder}")
else:
system(f"touch {folder}/{choice(NAMES)}{n}")
system(f"{config['CONFIG']['editor']} {folder}")
system(f"{config['CONFIG']['terminal']} {folder}")