mirror of
https://github.com/owenlejeune/zsh-plugins.git
synced 2025-11-20 22:30:55 -05:00
new custom plugins
This commit is contained in:
10
scripts/frand.py
Normal file
10
scripts/frand.py
Normal 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
24
scripts/randomnums.py
Normal 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))
|
||||
4
scripts/scripts.plugin.zsh
Normal file
4
scripts/scripts.plugin.zsh
Normal file
@@ -0,0 +1,4 @@
|
||||
SDIR="~/.oh-my-zsh/custom/plugins/scripts"
|
||||
|
||||
alias frand="python3 ${SDIR}/frand.py"
|
||||
alias randnums="python3 ${SDIR}/randomnums.py"
|
||||
Reference in New Issue
Block a user