mirror of
https://github.com/owenlejeune/zsh-plugins.git
synced 2025-11-19 05:50:52 -05:00
new scripts
This commit is contained in:
3
bitwarden/bitwarden.plugin.zsh
Normal file
3
bitwarden/bitwarden.plugin.zsh
Normal file
@@ -0,0 +1,3 @@
|
||||
export BW_SESSION="5q+MApwFfcaY7wGqB6ld7q9k2EUr763jSaJHeNeqX49biT6ZuRUHL1Y flnffNPB8O+egZCi//H9zqZoeN3Km0Q=="
|
||||
|
||||
alias "bw-search"="bw list items --search"
|
||||
@@ -19,9 +19,18 @@ if check_start:
|
||||
if i.startswith(start):
|
||||
fs.append(i)
|
||||
numitems = len(fs)
|
||||
i = randint(0,numitems-1)
|
||||
found = False
|
||||
while not found:
|
||||
j = randint(0,numitems-1)
|
||||
if fs[j][0] != ".":
|
||||
found = True
|
||||
print(fs[i])
|
||||
else:
|
||||
numitems = len(dirlist)
|
||||
found = False
|
||||
while not found:
|
||||
i = randint(0,numitems-1)
|
||||
if dirlist[i][0] != ".":
|
||||
found = True
|
||||
# i = randint(0,numitems-1)
|
||||
print(dirlist[i])
|
||||
|
||||
@@ -2,29 +2,40 @@ import sys
|
||||
from random import randint
|
||||
|
||||
check_start = False
|
||||
start = ''
|
||||
prefix = ''
|
||||
num = 1
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print("ERROR: Please include a filename")
|
||||
print("Usage: frand <FILENAME> [<INCLUDES>] [n=<NUM>]")
|
||||
sys.exit(0)
|
||||
|
||||
fn = sys.argv[1]
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
start = sys.argv[2]
|
||||
for i in range(2, len(sys.argv)):
|
||||
if sys.argv[i].startswith("n="):
|
||||
num = int(sys.argv[i][2:])
|
||||
else:
|
||||
prefix = sys.argv[i]
|
||||
check_start = True
|
||||
|
||||
|
||||
lines = []
|
||||
with open(fn) as f:
|
||||
for line in f:
|
||||
nline = line.replace("\n", "")
|
||||
lines.append(nline)
|
||||
|
||||
if check_start:
|
||||
for x in range(0, num):
|
||||
if check_start:
|
||||
line_sub = []
|
||||
for i in lines:
|
||||
if i.startswith(start):
|
||||
if i.startswith(prefix):
|
||||
line_sub.append(i)
|
||||
numitems = len(line_sub)
|
||||
i = randint(0,numitems-1)
|
||||
print(line_sub[i])
|
||||
else:
|
||||
else:
|
||||
numitems = len(lines)
|
||||
i = randint(0,numitems-1)
|
||||
print(lines[i])
|
||||
|
||||
@@ -3,3 +3,4 @@ SDIR="~/.oh-my-zsh/custom/plugins/scripts"
|
||||
alias frand="python3 ${SDIR}/frand.py"
|
||||
alias drand="python3 ${SDIR}/drand.py"
|
||||
alias randnums="python3 ${SDIR}/randomnums.py"
|
||||
alias sort-by-date="python3 ${SDIR}/sort-by-time.py"
|
||||
|
||||
20
scripts/sort-by-time.py
Normal file
20
scripts/sort-by-time.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
import datetime
|
||||
|
||||
dirn = sys.argv[1]
|
||||
dirlist = os.listdir(dirn)
|
||||
|
||||
dates = []
|
||||
|
||||
for f in dirlist:
|
||||
if f[:1] != '.' and os.path.isfile(dirn + "/" + f):
|
||||
fname = pathlib.Path(dirn + "/" + f)
|
||||
ctime = datetime.datetime.fromtimestamp(fname.stat().st_ctime)
|
||||
date = str(ctime)[:10]
|
||||
if date not in dates:
|
||||
if not os.path.isdir(dirn + "/" + date):
|
||||
dates.append(date)
|
||||
os.mkdir(dirn + "/" + date)
|
||||
os.rename(dirn + "/" + f, dirn + "/" + date + "/" + f)
|
||||
Reference in New Issue
Block a user