From e65b975b876b7a1af6cdeeef6693bf1f06ccfc34 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Mon, 2 Mar 2020 11:44:29 -0500 Subject: [PATCH 01/11] Update git.plugin.zsh --- git/git.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git/git.plugin.zsh b/git/git.plugin.zsh index 41e0170..a962d6d 100644 --- a/git/git.plugin.zsh +++ b/git/git.plugin.zsh @@ -3,6 +3,7 @@ alias gadda="gadd -A" alias gstatus="git status" alias gdiff="git diff" alias glog="git log" +alias glogg="git log --graph" alias glast="glog -p -1" alias gcheckout="git checkout" alias gcheckoutb="gcheckout -b" @@ -14,8 +15,11 @@ alias gcommit="git commit" alias gcommitm="git commit -m" alias gamend="gcommit --amend" alias gbranch="git branch" -alias rnmbranch="gbranch -m" +alias gbranchd="git branch -D" +alias grnmbranch="gbranch -m" alias gpushb="git push origin" +alias gundoc="git reset HEAD~" +alias greset="git checkout --" function gpush() { BRANCH="" From 2647f632b4cfa85ed8b0346cb6574bb0d1ed332d Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Thu, 5 Mar 2020 08:13:28 -0500 Subject: [PATCH 02/11] add dotfiles --- dotfiles/dotfiles.plugin.zsh | 2 + zshrc | 126 ----------------------------------- 2 files changed, 2 insertions(+), 126 deletions(-) create mode 100644 dotfiles/dotfiles.plugin.zsh delete mode 100644 zshrc diff --git a/dotfiles/dotfiles.plugin.zsh b/dotfiles/dotfiles.plugin.zsh new file mode 100644 index 0000000..4d73106 --- /dev/null +++ b/dotfiles/dotfiles.plugin.zsh @@ -0,0 +1,2 @@ +alias dotfile-make="sh ~/.dotfiles/tools/df-make.sh" +alias df-make="dotfile-make" diff --git a/zshrc b/zshrc deleted file mode 100644 index 9a6940d..0000000 --- a/zshrc +++ /dev/null @@ -1,126 +0,0 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH -export ANDROID_HOME=$HOME/Library/Android/sdk -export PATH=$PATH:$ANDROID_HOME/emulator -export PATH=$PATH:$ANDROID_HOME/tools -export PATH=$PATH:$ANDROID_HOME/tools/bin -export PATH=$PATH:$ANDROID_HOME/platform-tools -export PATH="/usr/local/sbin:$PATH" - -# Path to your oh-my-zsh installation. -export ZSH="/Users/owenlejeune/.oh-my-zsh" - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes -#ZSH_THEME="robbyrussell" -ZSH_THEME="pygmalion" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in ~/.oh-my-zsh/plugins/* -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=(autoenv - colored-man-pages - colorize - git - homebrew - macos - oneplus - osx - subliminal - telnet - thefuck - wd - xcode) - -source $ZSH/oh-my-zsh.sh -source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# ssh -# export SSH_KEY_PATH="~/.ssh/rsa_id" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -# ZSH -alias zshconfig="atom ~/.zshrc" -alias ohmyzsh="atom ~/.oh-my-zsh" -alias zshsource="source ~/.zshrc" -alias reset="cd && clear" - -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh - -test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" From ff00e6588479c39c85e67fc11a828cf2662f2d66 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Thu, 5 Mar 2020 08:14:50 -0500 Subject: [PATCH 03/11] remove zshrc --- zshrc | 125 ---------------------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 zshrc diff --git a/zshrc b/zshrc deleted file mode 100644 index 6006ac3..0000000 --- a/zshrc +++ /dev/null @@ -1,125 +0,0 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH -export ANDROID_HOME=$HOME/Library/Android/sdk -export PATH=$PATH:$ANDROID_HOME/emulator -export PATH=$PATH:$ANDROID_HOME/tools -export PATH=$PATH:$ANDROID_HOME/tools/bin -export PATH=$PATH:$ANDROID_HOME/platform-tools -export PATH="/usr/local/sbin:$PATH" - -# Path to your oh-my-zsh installation. -export ZSH="/Users/owenlejeune/.oh-my-zsh" - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes -# ZSH_THEME="robbyrussell" -ZSH_THEME="pygmalion" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to automatically update without prompting. -# DISABLE_UPDATE_PROMPT="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS=true - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in ~/.oh-my-zsh/plugins/* -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=(autoenv - colored-man-pages - colorize - git - homebrew - macos - oneplus - shell - subliminal - telnet - thefuck - wd - xcode) - -source $ZSH/oh-my-zsh.sh - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -alias zshconfig="vim ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" -alias ohmyzsh="atom ~/.oh-my-zsh" -alias zshsource="source ~/.zshrc" -alias reset="cd && clear" - -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh - -test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" From 6f4200dfd341fbceeb272528e8f23b2e74313b78 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Thu, 12 Mar 2020 10:39:14 -0400 Subject: [PATCH 04/11] new plugins --- bd/bd.plugin.zsh | 59 ++++++++++++++++++++++++++++++++++++++++++++ code/code.plugin.zsh | 7 ++++++ copy/copy.plugin.zsh | 3 +++ 3 files changed, 69 insertions(+) create mode 100755 bd/bd.plugin.zsh create mode 100755 code/code.plugin.zsh create mode 100755 copy/copy.plugin.zsh diff --git a/bd/bd.plugin.zsh b/bd/bd.plugin.zsh new file mode 100755 index 0000000..3f00073 --- /dev/null +++ b/bd/bd.plugin.zsh @@ -0,0 +1,59 @@ +#! /bin/bash +alias bd="bdfn -si" + +usage_error () { + cat << EOF +------------------------------------------------------------------ +Name: bd +Version: 1.02 + +------------------------------------------------------------------ +Description: Go back to a specified directory up in the hierarchy. + +------------------------------------------------------------------ +How to use: + +Please refer https://github.com/vigneshwaranr/bd + +EOF +} + +newpwd() { + oldpwd=$1 + case "$2" in + -s) + pattern=$3 + NEWPWD=$(echo $oldpwd | sed 's|\(.*/'$pattern'[^/]*/\).*|\1|') + ;; + -si) + pattern=$3 + NEWPWD=$(echo $oldpwd | perl -pe 's|(.*/'$pattern'[^/]*/).*|$1|i') + ;; + *) + pattern=$2 + NEWPWD=$(echo $oldpwd | sed 's|\(.*/'$pattern'/\).*|\1|') + esac +} + +bdfn() { + if [ $# -eq 0 ] + then + usage_error + elif [ "${@: -1}" = -v ] + then + usage_error + else + oldpwd=$(pwd) + + newpwd "$oldpwd" "$@" + + if [ "$NEWPWD" = "$oldpwd" ] + then + echo "No such occurrence." + else + echo $NEWPWD + cd "$NEWPWD" + fi + unset NEWPWD + fi +} diff --git a/code/code.plugin.zsh b/code/code.plugin.zsh new file mode 100755 index 0000000..fe181e9 --- /dev/null +++ b/code/code.plugin.zsh @@ -0,0 +1,7 @@ +alias vscode="code" +alias vs-code="code" +alias cdiff="code -d" +alias cadd="code -a" +alias cnew="code -n" +alias code-install="code --install-extension" +alias code-uninstall="code --uninstall-extension" diff --git a/copy/copy.plugin.zsh b/copy/copy.plugin.zsh new file mode 100755 index 0000000..5dad36a --- /dev/null +++ b/copy/copy.plugin.zsh @@ -0,0 +1,3 @@ +xcopy() { $1 | xclip -selection clipboard; } +xcopyf() { cat $1 | xclip -selection clipboard; } +xpaste() { xclip -selection clipboard -o; } From a32f50b8087f1b4db032e70f28c0b34bf224f041 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Mon, 28 Sep 2020 15:37:48 -0400 Subject: [PATCH 05/11] update additional zsh plugins --- zsh-autosuggestions | 2 +- zsh-syntax-highlighting | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 zsh-syntax-highlighting diff --git a/zsh-autosuggestions b/zsh-autosuggestions index 43f3bc4..ae315de 160000 --- a/zsh-autosuggestions +++ b/zsh-autosuggestions @@ -1 +1 @@ -Subproject commit 43f3bc4010b2c697d2252fdd8b36a577ea125881 +Subproject commit ae315ded4dba10685dbbafbfa2ff3c1aefeb490d diff --git a/zsh-syntax-highlighting b/zsh-syntax-highlighting new file mode 160000 index 0000000..62c5575 --- /dev/null +++ b/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit 62c5575848f1f0a96161243d18497c247c9f52df From 24796df740cc99d9a93ebff488d5450b593b8f17 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Tue, 29 Sep 2020 09:59:44 -0400 Subject: [PATCH 06/11] add plugin for linux --- linux/linux.plugin.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 linux/linux.plugin.zsh diff --git a/linux/linux.plugin.zsh b/linux/linux.plugin.zsh new file mode 100644 index 0000000..f77be47 --- /dev/null +++ b/linux/linux.plugin.zsh @@ -0,0 +1,14 @@ +alias fix-audio="pavucontrol" + +function open() { + DIR="." + if [[ $# -gt 0 ]]; + then + DIR="$1" + fi + gio open $DIR +} + +function trash() { + gio trash $@ +} From 73a0bf82990dead689a8d39c7529a9f3f95b4b56 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Tue, 29 Sep 2020 10:03:28 -0400 Subject: [PATCH 07/11] remove example custom plugin --- example/example.plugin.zsh | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 example/example.plugin.zsh diff --git a/example/example.plugin.zsh b/example/example.plugin.zsh deleted file mode 100644 index 406f274..0000000 --- a/example/example.plugin.zsh +++ /dev/null @@ -1,2 +0,0 @@ -# Add your own custom plugins in the custom/plugins directory. Plugins placed -# here will override ones with the same name in the main plugins directory. From b800a5d24b0f89422f8da0e56713dc217c48d39f Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Tue, 29 Sep 2020 10:04:44 -0400 Subject: [PATCH 08/11] restore example plugin --- example/example.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 example/example.plugin.zsh diff --git a/example/example.plugin.zsh b/example/example.plugin.zsh new file mode 100644 index 0000000..406f274 --- /dev/null +++ b/example/example.plugin.zsh @@ -0,0 +1,2 @@ +# Add your own custom plugins in the custom/plugins directory. Plugins placed +# here will override ones with the same name in the main plugins directory. From 16b7dc5fd15101283330fc5dcfed3968eac0c98f Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Fri, 8 Jan 2021 16:28:24 -0500 Subject: [PATCH 09/11] new custom plugins --- android/android.plugin.zsh | 1 + apps/apps.plugin.zsh | 3 +++ homebrew/homebrew.plugin.zsh | 11 ++++++++++- scripts/frand.py | 10 ++++++++++ scripts/randomnums.py | 24 ++++++++++++++++++++++++ scripts/scripts.plugin.zsh | 4 ++++ 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 android/android.plugin.zsh create mode 100644 apps/apps.plugin.zsh create mode 100644 scripts/frand.py create mode 100644 scripts/randomnums.py create mode 100644 scripts/scripts.plugin.zsh diff --git a/android/android.plugin.zsh b/android/android.plugin.zsh new file mode 100644 index 0000000..7237249 --- /dev/null +++ b/android/android.plugin.zsh @@ -0,0 +1 @@ +alias android-studio="open -a /Users/owenlejeune/Applications/JetBrains\ Toolbox/Android\ Studio.app" diff --git a/apps/apps.plugin.zsh b/apps/apps.plugin.zsh new file mode 100644 index 0000000..40b3612 --- /dev/null +++ b/apps/apps.plugin.zsh @@ -0,0 +1,3 @@ +VNC_VIEWER="VNC\ Viewer" + +alias vnc_viewer="open -a $VNC_VIEWER" diff --git a/homebrew/homebrew.plugin.zsh b/homebrew/homebrew.plugin.zsh index 558ed2c..882cb1e 100644 --- a/homebrew/homebrew.plugin.zsh +++ b/homebrew/homebrew.plugin.zsh @@ -1 +1,10 @@ -alias brewup="brew update && brew upgrade && brew cleanup && brew doctor && brew cask upgrade" +function brewup() { + echo "***BREW UPDATE***" + brew update + echo "***BREW UPGRADE***" + brew upgrade + echo "***BREW CLEANUP***" + brew cleanup + echo "***BREW DOCTOR***" + brew doctor +} diff --git a/scripts/frand.py b/scripts/frand.py new file mode 100644 index 0000000..1511366 --- /dev/null +++ b/scripts/frand.py @@ -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]) + diff --git a/scripts/randomnums.py b/scripts/randomnums.py new file mode 100644 index 0000000..b47bc1b --- /dev/null +++ b/scripts/randomnums.py @@ -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 []") + 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)) diff --git a/scripts/scripts.plugin.zsh b/scripts/scripts.plugin.zsh new file mode 100644 index 0000000..296a263 --- /dev/null +++ b/scripts/scripts.plugin.zsh @@ -0,0 +1,4 @@ +SDIR="~/.oh-my-zsh/custom/plugins/scripts" + +alias frand="python3 ${SDIR}/frand.py" +alias randnums="python3 ${SDIR}/randomnums.py" From 2af3e608f7a5bdc0291b8c0656645c61222e20e6 Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Wed, 20 Jan 2021 15:06:34 -0500 Subject: [PATCH 10/11] update scripts --- scripts/drand.py | 27 +++++++++++++++++++++++++++ scripts/frand.py | 32 ++++++++++++++++++++++++++------ scripts/scripts.plugin.zsh | 1 + 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 scripts/drand.py diff --git a/scripts/drand.py b/scripts/drand.py new file mode 100644 index 0000000..e35bb05 --- /dev/null +++ b/scripts/drand.py @@ -0,0 +1,27 @@ +import os, os.path +import sys +from random import randint + +check_start = False +start = '' + +dirn = sys.argv[1] + +if len(sys.argv) > 2: + start = sys.argv[2] + check_start = True + +dirlist = os.listdir(dirn) + +if check_start: + fs = [] + for i in dirlist: + if i.startswith(start): + fs.append(i) + numitems = len(fs) + i = randint(0,numitems-1) + print(fs[i]) +else: + numitems = len(dirlist) + i = randint(0,numitems-1) + print(dirlist[i]) diff --git a/scripts/frand.py b/scripts/frand.py index 1511366..ec67901 100644 --- a/scripts/frand.py +++ b/scripts/frand.py @@ -1,10 +1,30 @@ -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]) +check_start = False +start = '' +fn = sys.argv[1] + +if len(sys.argv) > 2: + start = sys.argv[2] + check_start = True + +lines = [] +with open(fn) as f: + for line in f: + nline = line.replace("\n", "") + lines.append(nline) + +if check_start: + line_sub = [] + for i in lines: + if i.startswith(start): + line_sub.append(i) + numitems = len(line_sub) + i = randint(0,numitems-1) + print(line_sub[i]) +else: + numitems = len(lines) + i = randint(0,numitems-1) + print(lines[i]) diff --git a/scripts/scripts.plugin.zsh b/scripts/scripts.plugin.zsh index 296a263..0f9fa0c 100644 --- a/scripts/scripts.plugin.zsh +++ b/scripts/scripts.plugin.zsh @@ -1,4 +1,5 @@ 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" From 1a2773ac76bfd41f5582433bab9f6c2b14918f1c Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Wed, 24 Mar 2021 11:50:44 -0400 Subject: [PATCH 11/11] new scripts --- bitwarden/bitwarden.plugin.zsh | 3 +++ scripts/drand.py | 13 ++++++++-- scripts/frand.py | 43 +++++++++++++++++++++------------- scripts/scripts.plugin.zsh | 1 + scripts/sort-by-time.py | 20 ++++++++++++++++ 5 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 bitwarden/bitwarden.plugin.zsh create mode 100644 scripts/sort-by-time.py diff --git a/bitwarden/bitwarden.plugin.zsh b/bitwarden/bitwarden.plugin.zsh new file mode 100644 index 0000000..8ec488a --- /dev/null +++ b/bitwarden/bitwarden.plugin.zsh @@ -0,0 +1,3 @@ +export BW_SESSION="5q+MApwFfcaY7wGqB6ld7q9k2EUr763jSaJHeNeqX49biT6ZuRUHL1Y flnffNPB8O+egZCi//H9zqZoeN3Km0Q==" + +alias "bw-search"="bw list items --search" diff --git a/scripts/drand.py b/scripts/drand.py index e35bb05..fc84edf 100644 --- a/scripts/drand.py +++ b/scripts/drand.py @@ -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) - i = randint(0,numitems-1) + found = False + while not found: + i = randint(0,numitems-1) + if dirlist[i][0] != ".": + found = True + # i = randint(0,numitems-1) print(dirlist[i]) diff --git a/scripts/frand.py b/scripts/frand.py index ec67901..b095f31 100644 --- a/scripts/frand.py +++ b/scripts/frand.py @@ -2,13 +2,23 @@ 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 [] [n=]") + sys.exit(0) fn = sys.argv[1] -if len(sys.argv) > 2: - start = sys.argv[2] - check_start = True +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: @@ -16,15 +26,16 @@ with open(fn) as f: nline = line.replace("\n", "") lines.append(nline) -if check_start: - line_sub = [] - for i in lines: - if i.startswith(start): - line_sub.append(i) - numitems = len(line_sub) - i = randint(0,numitems-1) - print(line_sub[i]) -else: - numitems = len(lines) - i = randint(0,numitems-1) - print(lines[i]) +for x in range(0, num): + if check_start: + line_sub = [] + for i in lines: + if i.startswith(prefix): + line_sub.append(i) + numitems = len(line_sub) + i = randint(0,numitems-1) + print(line_sub[i]) + else: + numitems = len(lines) + i = randint(0,numitems-1) + print(lines[i]) diff --git a/scripts/scripts.plugin.zsh b/scripts/scripts.plugin.zsh index 0f9fa0c..81fe896 100644 --- a/scripts/scripts.plugin.zsh +++ b/scripts/scripts.plugin.zsh @@ -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" diff --git a/scripts/sort-by-time.py b/scripts/sort-by-time.py new file mode 100644 index 0000000..62cae62 --- /dev/null +++ b/scripts/sort-by-time.py @@ -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)