Copied bash scripts and fixed shebangs

This commit is contained in:
Wryn Wagner 2019-12-02 10:16:05 -07:00
parent f5b9664b6b
commit 67e48cb7bc
12 changed files with 443 additions and 0 deletions

View File

@ -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

50
zsh/bashcolors Normal file
View File

@ -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\]"

3
zsh/fun Normal file
View File

@ -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"'

6
zsh/linux/archfun Normal file
View File

@ -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/*";

36
zsh/osx/color-ls Normal file
View File

@ -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'

59
zsh/osx/osxfun Normal file
View File

@ -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'

96
zsh/osx/osxtimer Normal file
View File

@ -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';

39
zsh/rc Normal file
View File

@ -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

79
zsh/rentdynamics Normal file
View File

@ -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:'

27
zsh/school Normal file
View File

@ -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;
}

15
zsh/time Normal file
View File

@ -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;
}

16
zsh/utility Normal file
View File

@ -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';