new custom plugins

This commit is contained in:
2021-01-08 16:28:24 -05:00
parent b800a5d24b
commit 16b7dc5fd1
6 changed files with 52 additions and 1 deletions

10
scripts/frand.py Normal file
View File

@@ -0,0 +1,10 @@
import os, os.path
import sys
from random import randint
dirn = sys.argv[1]
dirlist = os.listdir(dirn)
numitems = len(dirlist)
i = randint(0,numitems-1)
print(dirlist[i])

24
scripts/randomnums.py Normal file
View File

@@ -0,0 +1,24 @@
from random import randrange
import sys
#num = int(input("Enter a number: "))
#num2 = int(input("How many numbers: "))
args = len(sys.argv)
if args<3 or args>4:
print("Invalid command\n usage: randnums <MIN> <MAX> [<NUM>]")
quit()
nmin = int(sys.argv[1])
nmax = int(sys.argv[2])
nnum = 1 if args==3 else int(sys.argv[3])
if nmin>=nmax:
print("Error: min must be less than max")
quit()
if nnum <= 0:
print("Error: num must be greater than 0")
quit()
for x in range(0, nnum):
print(randrange(nmin, nmax))

View File

@@ -0,0 +1,4 @@
SDIR="~/.oh-my-zsh/custom/plugins/scripts"
alias frand="python3 ${SDIR}/frand.py"
alias randnums="python3 ${SDIR}/randomnums.py"