From 67e48cb7bce446c81f8f083c06050b516a2d339e Mon Sep 17 00:00:00 2001 From: Wryn Wagner Date: Mon, 2 Dec 2019 10:16:05 -0700 Subject: [PATCH] Copied bash scripts and fixed shebangs --- redirect | 17 +++++++++ zsh/bashcolors | 50 ++++++++++++++++++++++++ zsh/fun | 3 ++ zsh/linux/archfun | 6 +++ zsh/osx/color-ls | 36 ++++++++++++++++++ zsh/osx/osxfun | 59 +++++++++++++++++++++++++++++ zsh/osx/osxtimer | 96 +++++++++++++++++++++++++++++++++++++++++++++++ zsh/rc | 39 +++++++++++++++++++ zsh/rentdynamics | 79 ++++++++++++++++++++++++++++++++++++++ zsh/school | 27 +++++++++++++ zsh/time | 15 ++++++++ zsh/utility | 16 ++++++++ 12 files changed, 443 insertions(+) create mode 100644 zsh/bashcolors create mode 100644 zsh/fun create mode 100644 zsh/linux/archfun create mode 100644 zsh/osx/color-ls create mode 100644 zsh/osx/osxfun create mode 100644 zsh/osx/osxtimer create mode 100644 zsh/rc create mode 100644 zsh/rentdynamics create mode 100644 zsh/school create mode 100644 zsh/time create mode 100644 zsh/utility diff --git a/redirect b/redirect index 1d080eb..726cfaf 100755 --- a/redirect +++ b/redirect @@ -12,6 +12,10 @@ grep '.wryn' $HOME/.vimrc >/dev/null 2>/dev/null \ && echo already set up vim rc \ || echo source $RC_DIR/vim/rc.vim >> $HOME/.vimrc; +grep '.wryn' $HOME/.zshrc >/dev/null 2>/dev/null \ + && echo already set up zsh rc \ + || echo source $RC_DIR/zsh/rc >> $HOME/.zshrc; + LOCAL_DIR_SETUP="$HOME/.my_bash_env" if [ ! -f "$LOCAL_DIR_SETUP" ]; then touch "$LOCAL_DIR_SETUP"; @@ -23,6 +27,18 @@ else echo 'bash environment variables already set up' fi +LOCAL_ZSH_SETUP="$HOME/.my_zsh_env" +if [ ! -f "$LOCAL_ZSH_SETUP" ]; then + touch "$LOCAL_ZSH_SETUP"; + echo '#!/bin/zsh' >> $LOCAL_ZSH_SETUP + echo 'RD_PATH="$HOME/RentDynamics";' >> $LOCAL_ZSH_SETUP + echo 'SCHOOL_ZSH="$HOME/School";' >> $LOCAL_ZSH_SETUP + echo 'DOTWRYN="$HOME/.wryn";' >> $LOCAL_ZSH_SETUP +else + echo 'zsh environment already set up'; +fi + + LOCAL_VIM_SETUP="$HOME/.my_vim_env" if [ ! -f "$LOCAL_VIM_SETUP" ]; then touch "$LOCAL_VIM_SETUP"; @@ -35,3 +51,4 @@ if [ ! -f "$LOCAL_VIM_SETUP" ]; then else echo 'vim environment variables already set up' fi + diff --git a/zsh/bashcolors b/zsh/bashcolors new file mode 100644 index 0000000..78e3d62 --- /dev/null +++ b/zsh/bashcolors @@ -0,0 +1,50 @@ +#!/bin/zsh +# Regular +txtblk="$(tput setaf 0 2>/dev/null || echo '\e[0;30m')" # Black +txtred="$(tput setaf 1 2>/dev/null || echo '\e[0;31m')" # Red +txtgrn="$(tput setaf 2 2>/dev/null || echo '\e[0;32m')" # Green +txtylw="$(tput setaf 3 2>/dev/null || echo '\e[0;33m')" # Yellow +txtblu="$(tput setaf 4 2>/dev/null || echo '\e[0;34m')" # Blue +txtpur="$(tput setaf 5 2>/dev/null || echo '\e[0;35m')" # Purple +txtcyn="$(tput setaf 6 2>/dev/null || echo '\e[0;36m')" # Cyan +txtwht="$(tput setaf 7 2>/dev/null || echo '\e[0;37m')" # White + +# Bold +bldblk="$(tput setaf 0 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;30m')" # Black +bldred="$(tput setaf 1 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;31m')" # Red +bldgrn="$(tput setaf 2 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;32m')" # Green +bldylw="$(tput setaf 3 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;33m')" # Yellow +bldblu="$(tput setaf 4 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;34m')" # Blue +bldpur="$(tput setaf 5 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;35m')" # Purple +bldcyn="$(tput setaf 6 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;36m')" # Cyan +bldwht="$(tput setaf 7 2>/dev/null)$(tput bold 2>/dev/null || echo '\e[1;37m')" # White + +# Underline +undblk="$(tput setaf 0 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;30m')" # Black +undred="$(tput setaf 1 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;31m')" # Red +undgrn="$(tput setaf 2 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;32m')" # Green +undylw="$(tput setaf 3 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;33m')" # Yellow +undblu="$(tput setaf 4 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;34m')" # Blue +undpur="$(tput setaf 5 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;35m')" # Purple +undcyn="$(tput setaf 6 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;36m')" # Cyan +undwht="$(tput setaf 7 2>/dev/null)$(tput smul 2>/dev/null || echo '\e[4;37m')" # White + +# Background +bakblk="$(tput setab 0 2>/dev/null || echo '\e[40m')" # Black +bakred="$(tput setab 1 2>/dev/null || echo '\e[41m')" # Red +bakgrn="$(tput setab 2 2>/dev/null || echo '\e[42m')" # Green +bakylw="$(tput setab 3 2>/dev/null || echo '\e[43m')" # Yellow +bakblu="$(tput setab 4 2>/dev/null || echo '\e[44m')" # Blue +bakpur="$(tput setab 5 2>/dev/null || echo '\e[45m')" # Purple +bakcyn="$(tput setab 6 2>/dev/null || echo '\e[46m')" # Cyan +bakwht="$(tput setab 7 2>/dev/null || echo '\e[47m')" # White + +# Reset +txtrst="$(tput sgr 0 2>/dev/null || echo '\e[0m')" # Text Reset + +parse_git_branch(){ + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/' +} + +# zsh prompt +PS1="\[$bldylw\] ☕ \[$txtblu\]\u\[$txtred\] :: \[$txtgrn\]\[$txtylw\]\w\[$bldcyn\]\$(parse_git_branch)\[$txtgrn\]$DEFAULT \n \$ \[$txtrst\]" diff --git a/zsh/fun b/zsh/fun new file mode 100644 index 0000000..3d6b90e --- /dev/null +++ b/zsh/fun @@ -0,0 +1,3 @@ +#!/bin/zsh +alias cheerup="clear; echo; fortune | cowsay -f stegosaurus | lolcat; echo;" +alias netrogue='nethack -u "w0ryn-rog-hum-cha-mal"' diff --git a/zsh/linux/archfun b/zsh/linux/archfun new file mode 100644 index 0000000..294d2c9 --- /dev/null +++ b/zsh/linux/archfun @@ -0,0 +1,6 @@ +#!/bin/zsh + +# dependency :: feh +alias bgrandomizer="feh --randomize --bg-fill $HOME/.wallpaper/1/* $HOME/.wallpaper/2/* $HOME/.wallpaper/3/*"; +# temp +alias bgrandomizer="feh --randomize --bg-fill $HOME/.wallpaper/* $HOME/.wallpaper/* $HOME/.wallpaper/*"; diff --git a/zsh/osx/color-ls b/zsh/osx/color-ls new file mode 100644 index 0000000..4aa46a0 --- /dev/null +++ b/zsh/osx/color-ls @@ -0,0 +1,36 @@ +#!/bin/zsh +# Colors are organized into (Foreground)(Background) bits as seen below: +# ======== +# 1 - Directory +# 2 - Symbolic link +# 3 - Socket +# 4 - Pipe +# 5 - Executable +# 6 - Block special +# 7 - Character special +# 8 - Executable with setgid bit set +# 9 - Executable with setgid bit set +# 10- Directory writable to others, with sticky bit +# 11- Directory writable to others, without sticky bit +# ======== +# a black +# b red +# c green +# d brown +# e blue +# f magenta +# g cyan +# h light grey +# CAPITAL (BOLD) +# x default + +# actual colorscheme +export LSCOLORS="ExxxxxDxBxxxxxxxxxxxxx" + +# for OSX, fixes spacing issues +f_notabs=0 + +# default ls to use defined colorscheme +alias ls='ls -G' + + diff --git a/zsh/osx/osxfun b/zsh/osx/osxfun new file mode 100644 index 0000000..4d6f4c1 --- /dev/null +++ b/zsh/osx/osxfun @@ -0,0 +1,59 @@ +#!/bin/zsh + +function voicesed() { sed 's/\([^ ]*\) .*/\1/;'; } +function voicelist() { say -v ? | voicesed; } +function voicelistenglish() { say -v ? | grep 'en_' | voicesed; } +function voicerandom() { voicelistenglish | shuf -n 1; } + +function voicelistnormal() { + voicelistenglish | + sed '/Trinoids/d;/Zarvox/d;/Deranged/d;/Hysterical/d;/Bahh/d;/Bubbles/d' +} +function voicerandomnormal() { voicelistnormal | shuf -n 1; } + +function sayvoices() { + for voice in $(voicelist); do + say -v "$voice" $(say -v ? | grep $voice | sed 's/[^#]*# //'); + done +} + +function sayone() { + local voice=$(voicerandom); + say -v "$voice" $(say -v ? | grep $voice | sed 's/[^#]*# //'); +} + + +function meme { + local DIRECTORY="$HOME/Pictures/jest"; + + [ ! -d $DIRECTORY ] && echo "No meme directory found :c"; + + echo; + imgcat $DIRECTORY/$1 + echo; +} +_meme () { # autocompletion + # Set + local cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $(compgen -W "$(ls $HOME/Pictures/jest)" -- $cur) ) +} +complete -F _meme meme; + +function pika { + local DIRECTORY="$HOME/Pictures/pika"; + + [ ! -d $DIRECTORY ] && echo "Pikachu directory required." && exit 1; + + # count the pikas + IMAGE_COUNT=$(ls -l $DIRECTORY | wc -l); + let "IMAGE_COUNT=IMAGE_COUNT-1"; + + # pick a random gif from the pikachu directory + IMAGE="$DIRECTORY/$((RANDOM % $IMAGE_COUNT)).gif"; + + echo; + imgcat $IMAGE + echo; +} + +alias pikabox='while true; do reset; pika; sleep 120; done' diff --git a/zsh/osx/osxtimer b/zsh/osx/osxtimer new file mode 100644 index 0000000..8be3152 --- /dev/null +++ b/zsh/osx/osxtimer @@ -0,0 +1,96 @@ +#!/bin/zsh +function osxtimer() { + # dependency check + #termdown --version >/dev/null 2>&1 || { echo osxtimer requires 'termdown'; exit 1; } + #lolcat --version >/dev/null 2>&1 || lolcatError='`lolcat` is not installed'; + #figlet --version >/dev/null 2>&1 || figletError='`figlet` is not installed'; + + # set defaults + local msg; + local timestring='10s'; + local voice; + local critical; + local dontsaycountdown; + local dontsaymessage; + local dowait; + local dontdisplaymessage; + local displayHelp; + + unset OPTIND; + while getopts "MVTYhwm:t:c:v:" opt; do + case $opt in + m) msg=$OPTARG ;; # optional message + M) dontdisplaymessage=t ;; # don't display message (but maybe say it) + t) timestring=$OPTARG ;; # termdown countdown string + c) critical=$OPTARG ;; # optional critical seconds remaining + v) voice=$OPTARG ;; # optional voice for critical seconds remaining + V) voice=$(voicerandom) ;; # select random voice + T) dontsaycountdown=t; ;; # don't readout countdown + V) dontsaymessage=t; ;; # don't readout message after countdown + w) dowait=t; ;; # don't wait for user input after the timer + h) displayHelp=t; ;; # display help message + :) echo option -$OPTARG requires an argument; displayHelp=t; + ;; + esac + done + unset OPTIND; + + # exit on fail + if [ $displayHelp ]; then + printf " +Correct usage: + [-t]\t countdown amount as a timestring used in 'termdown' + [-m]\t display message after countdown is finished + [-c]\t critical seconds param for 'termdown' + [-v]\t 'say' voice used for reading the message and countdown + [-V]\t select random voice for message and timer readout + [-T]\t used with -v or -V :: don't readout the countdown + [-Y]\t used with -v or -V :: don't readout the message + [-w]\t wait for user input after the timer +\n"; + return 1; + fi; + + # verify that the voice exists + say -v ? | grep $voice >/dev/null 2>&1 || unset voice; + + local termdownargs="$timestring "; + [[ $critical ]] && termdownargs="$termdownargs -c $critical"; + [[ $voice ]] && [ -z $dontsaycountdown ] && termdownargs="$termdownargs -v $voice"; + termdown $termdownargs; + + [[ $msg ]] && [ -z $dontdisplaymessage ] && figlet "$msg" | lolcat; + [[ $voice ]] && [ -z $dontsaymessage ] && say -v "$voice" "$msg"; + + [[ $dowait ]] && read -n 1; # wait for user input +} + +function rdexercise() { + local message='Plank time!'; + local delay='1h30m'; + local count; + + # flagged arguments + unset OPTIND; + while getopts "m:t:c:" opt; do + case $opt in + m) message=$OPTARG ;; # optional message + t) timeout=$OPTARG ;; # termdown countdown string + c) count=$OPTARG ;; # length of exercise as a timestring + esac + done + unset OPTIND; + + # operation loop + while true; do + rdstart >/dev/null 2>&1; + clear; osxtimer -VT -m "$message" -t "$delay"; + rdplank >/dev/null 2>&1; + + read -n 1; clear; + [[ $count ]] && osxtimer -c 10 -m "Done" -v "$(voicerandomnormal)" -t "$count"; + done +} + +alias planktimer='rdexercise -c'; +alias pushuptimer='rdexercise -m "Push-up time!" -t "1h" -c'; diff --git a/zsh/rc b/zsh/rc new file mode 100644 index 0000000..2e05ab9 --- /dev/null +++ b/zsh/rc @@ -0,0 +1,39 @@ +#!/bin/zsh +source "$HOME/.my_zsh_env" + +RC_DIR="$DOTWRYN/zsh" + +# source .wryn/zsh files +for file in $(find $RC_DIR -maxdepth 1 -type f ! -name 'rc'); do source $file; done; + +# osx +if [[ "$OSTYPE" == "darwin"* ]]; then + for file in $(find $RC_DIR/osx -type f); do source $file; done; +fi + +# linux +if [[ "$OSTYPE" == "linux-gnu" ]]; then + for file in $(find $RC_DIR/linux -type f); do source $file; done; +fi + +# --- ViM as default editor ----------------------------------- +export EDITOR='vim' +export VISUAL='vim' + +# --- Welcome message ----------------------------------------- +exec figlet "Welcome, beautiful" | lolcat; echo; cowsay -p "damn u sexy" | lolcat; + +alias restart='clear; source ~/.zshrc; echo' + +# --- !@#$ Aliases -------------------------------------------- +alias clera='clear'; +alias sl='sl -alF | lolcat'; + + +# --- BASH RC DEPENDENCIES ------------------------------------ +# sl +# lolcat +# figlet +# fortune +# vim +# cowsay diff --git a/zsh/rentdynamics b/zsh/rentdynamics new file mode 100644 index 0000000..829a4a8 --- /dev/null +++ b/zsh/rentdynamics @@ -0,0 +1,79 @@ +#!/bin/zsh +alias rdvmail='VMAIL_HOME=~/.vmail/business1 vmail'; + +function rnt() { +# filestructure needed: +# RD_PATH/project-name +# > /code (git clone) +# > /env (virtualenv) + deactivate >/dev/null 2>/dev/null || deactivate_node >/dev/null 2>/dev/null; + cd $RD_PATH; + + local cont=0; + [ $1 ] \ + && [ -d $RD_PATH/$1 ] \ + && cd $1 >/dev/null 2>/dev/null \ + || cont=1; + + if [ $cont -eq 0 ]; then + [ -f ./env/bin/activate ] \ + && source ./env/bin/activate \ + || echo No environment here, boss!; + [ -d ./code ] \ + && cd code \ + || echo No source folder here!; + fi +} +_rnt () { # autocompletion + # Set + local cur=${COMP_WORDS[COMP_CWORD]} + COMPREPLY=( $(compgen -W "$(ls $RD_PATH)" -- $cur) ) +} +complete -F _rnt rnt; + +function refresh_rd_db() { + psql postgres -c "DROP DATABASE rentdynamics;" + psql postgres -c "CREATE DATABASE rentdynamics with owner rd;" + psql postgres -c "DROP DATABASE rdrentplus;" + psql postgres -c "CREATE DATABASE rdrentplus with owner rd;" +} + +function rntbranchcleanup() { + printf "\nInitializing branch cleanup...\n\n" + for dir in $(ls $RD_PATH); do + rnt $dir >/dev/null 2>/dev/null; + if [ -d .git ]; then + printf " - %s\e[1;34m %s\e[0m..." "clearing repository" "$dir"; + git branch -d $(git branch | sed -E "/master|\*/d") >/dev/null 2>/dev/null; + printf "\e[1;32m%s\e[0m\n" " DONE"; + else + printf " - \e[1;34m%s\e[1;31m %s\e[0m" "$dir" "is not a git repository"; + fi + rnt; + done; + printf "\n\n\e[1;36m%s\e[1;35m %s\e[0m\n\n" "RentDynamics" "repository branches all clean!"; +} + + +function rdstatus() { + slack status edit "$1" $2 >/dev/null 2>&1; +} + +alias rdclearstatus='slack status clear >/dev/null 2>&1' + +alias rdstart='rdboost' +alias rdstart2='rdpanic' +alias rdplank='rdstatus "plank time!" :evergreen_tree:' +alias rdstop='rdstatus "not making money" :sunglasses:' +alias rdstop2='rdride' +alias rdmeal='rdstatus "so hungry..." :hamburger:' +alias rdturbo='rdstatus "ZOOOM" :turbo:' +alias rdsuper='rdstatus "AAAAAAAAAAAAHHHHHHHHH" :gohan:' +alias rdmeeting='rdstatus "afk" :necktie:' +alias rdbudget='rdstatus "did somebody say skee-ball??" :scales:' +alias rdcheese='rdstatus "only the most important things on my mind" :cheese_wedge:' +alias rdfoos='rdstatus "I will defeat Mike... someday..." :soccer:' +alias rdlax='rdstatus "BELAAAAAAAX" :exploding_head:' +alias rdpanic='rdstatus "dont panic!" :exclamation:' +alias rdboost='rdstatus "Use your heart, and boost fire!" :boost_fire:' +alias rdride='rdstatus "probably riding" :man-biking:' diff --git a/zsh/school b/zsh/school new file mode 100644 index 0000000..33aa912 --- /dev/null +++ b/zsh/school @@ -0,0 +1,27 @@ +#!/bin/zsh +# ------------------------------------- +# -- School (Fall 2019) ------------- +# ------------------------------------- + +alias school="cd $SCHOOL_DIR"; +alias classes="cat $SCHOOL_DIR/.classes"; + +alias cs5680='school; cd cs5680__computer_vision'; +alias compvis='cs5680' +alias cs5600='school; cd cs5600__intelligent_systems'; +alias intsys='cs5600' +alias engr3080='school; cd engr3080__tech_writing'; +alias techwrit='engr3080' +alias phil1120='school; cd phil1120__social_ethics'; +alias socioet='phil1120' + + +HW_TEMPLATE="$DOTWRYN/latex/homework_template.tex" +function hw() { + # Make new homework .tex from default template + [ ! $1 ] && echo "Homework filename required" && exit 1; + + NEW_HW="./$1.tex"; + [ ! -f $NEW_HW ] && cp $HW_TEMPLATE $NEW_HW; + vim $NEW_HW; +} diff --git a/zsh/time b/zsh/time new file mode 100644 index 0000000..62d1ce6 --- /dev/null +++ b/zsh/time @@ -0,0 +1,15 @@ +#!/bin/zsh +alias datereadable='date +"%A %B %d, %Y"' + +function saydate() { + local todaysdate="$(date +'%A %B %d, %Y')" + local currenthour="$(date +'%H')" + local currentminute="$(date +'%M')" + [[ $currentminute -lt 10 ]] && currentminute="O $currentminute"; + + say "it's currently $currenthour $currentminute on $todaysdate"; +} + +function clock() { + watch -c -t -n1 "date +'%H : %M : %S' | figlet" | lolcat; +} diff --git a/zsh/utility b/zsh/utility new file mode 100644 index 0000000..bd1ebdf --- /dev/null +++ b/zsh/utility @@ -0,0 +1,16 @@ +#!/bin/zsh + +# --- Note-taking facilitated --------------------------------- +NOTE_PATH='/Users/w0ryn/Documents/notes'; +NOTE_EXTENSION='.txt'; +alias mynotes='cd $NOTE_PATH'; +function note() { vim $NOTE_PATH/$1$NOTE_EXTENSION; } +function notes() { NOTE="$NOTE_PATH/$1$NOTE_EXTENSION"; [ $1 ] && [ -f $NOTE ] && vim $NOTE || vim $NOTE_PATH; } + +# --- GIT ----------------------------------------------------- +alias gitbranchcleanup='git branch -d $(git branch | sed -E "/develop|master|\*/d")' + + +alias pd='pushd'; +alias qd='popd'; +alias ds='dirs';