Compare commits

..

6 Commits

Author SHA1 Message Date
244c188deb v2.5.2
=====================================================================

--- Changes ------------------------------

- added __GET_RANDOM_COLOR for funsies
2022-08-16 23:29:10 -06:00
5c882597da v2.5.1
=====================================================================

--- Bug Fixes ----------------------------

- git/package/install didn't create build dir if it did not exist
2022-08-16 18:48:56 -06:00
4047aad29e fixed credits bug with dashes 2022-08-16 18:44:25 -06:00
6333a2f6b8 v2.5.0
=====================================================================

--- New Scripts --------------------------

zsh )
  vundle-vim helpers
   - vim/vundle/edit-build-actions
   - vim/vundle/install
   - vim/vundle/rebuild

  quick install-from-source scripts
   - git/package/install
   - git/package/build    (install --only-build)
   - git/package/download (install --only-pull)
   - git/package/update   (install --update)

  config sym-linker (for source-controlled .configs)
   - config/update    (symlinks + terminfo)
   - config/symlinks  (set all symlinks from settings)
   - config/settings  (edit settings which aren't scwrypts env variables)
   - config/terminfo  (load all terminfo from settings)

--- Changes ------------------------------

- helper comments are now inserted in all env files
- removed underscore prefix for standard AWS environment variables
- added "opening" and "finished editing" comments to __EDIT util
- added __USAGE to format $USAGE variable to std:err
- added __ERROR_CHECK to exit if any __ERROR(s) were called
2022-08-16 18:26:55 -06:00
a740a66870 v2.4.0
=====================================================================

--- New Scripts --------------------------

zsh )
  memo program; quickly take notes!
   - memo/open
   - memo/remove
2022-08-10 00:46:07 -06:00
96992e9344 v2.3.0
=====================================================================

--- New Scripts --------------------------

zsh )
  latex + latex template engine
   - latex/build-pdf
   - latex/cleanup
   - latex/create-new
   - latex/get-pdf
   - latex/open-pdf

  beta SQL script -- got tired of floating this; works, but only OK
   - db/run-sql/postgres

--- Changes ------------------------------

- Added 'math', 'basic', and 'times-new-roman' templates to latex
- Added 'readlink' to list of required coreutils
- Added __INPUT to read into a variable with prompt (zsh/utils/io)
- Added $EXECUTION_DIR to interact with the user's working directory

--- Bug Fixes ----------------------------

- subscwrypts no longer force stdout/stderr to tty
2022-08-09 21:51:31 -06:00
60 changed files with 1064 additions and 52 deletions

View File

@ -1,10 +1,10 @@
#!/bin/zsh
export AWS_ACCOUNT=
export AWS_PROFILE=
export AWS_REGION=
export AWS__EFS__LOCAL_MOUNT_POINT=
export AWS__S3__MEDIA_BUCKET=
export AWS__S3__MEDIA_TARGETS=
export REDIS_AUTH=
export REDIS_HOST=
export REDIS_PORT=
export _AWS_ACCOUNT=
export _AWS_PROFILE=
export _AWS_REGION=

View File

@ -0,0 +1,12 @@
AWS_ACCOUNT | standard AWS environment variables used by awscli and other tools
AWS_PROFILE |
AWS_REGION |
AWS__EFS__LOCAL_MOUNT_POINT | fully-qualified path to mount the EFS drive
AWS__S3__MEDIA_BUCKET | s3 bucket name and filesystem targets for media backups
AWS__S3__MEDIA_TARGETS |
REDIS_AUTH | redis connection credentials
REDIS_HOST |
REDIS_PORT |

View File

@ -45,7 +45,6 @@ After determining which script to run, if no environment has been specified, Scw
Set environment variable `CI=true` (and use the no install method) to run in an automated pipeline.
There are a few notable changes to this runtime:
- **The Scwrypts sandbox environment will not load.** All variables will be read from context.
- The underscore-prefixed `_AWS_(PROFILE|REGION|ACCOUNT)` variables will be read from the standard `AWS_` variables
- User yes/no prompts will **always be YES**
- Other user input will default to an empty string
- Logs will not be captured

View File

@ -15,17 +15,27 @@ __ENV_TEMPLATE=$SCWRYPTS_ROOT/.env.template
#####################################################################
__GET_PATH_TO_RELATIVE_ARGUMENT() {
[[ $1 =~ ^[.] ]] \
&& echo $(readlink -f "$EXECUTION_DIR/$1") \
|| echo "$1" \
;
true
}
#####################################################################
__RUN_SCWRYPT() {
((SUBSCWRYPT+=1))
printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "
echo " BEGIN SUBSCWRYPT : $(basename $1)"
{ printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "; } >&2
echo " BEGIN SUBSCWRYPT : $@" >&2
SUBSCWRYPT=$SUBSCWRYPT SCWRYPTS_ENV=$ENV_NAME \
"$SCWRYPTS_ROOT/scwrypts" $@
EXIT_CODE=$?
printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "
echo " END SUBSCWRYPT : $(basename $1)"
{ printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "; } >&2
echo " END SUBSCWRYPT : $1" >&2
((SUBSCWRYPT-=1))
return $EXIT_CODE

30
run
View File

@ -1,32 +1,33 @@
#!/bin/zsh
export EXECUTION_DIR=$(pwd)
SCWRYPTS_ROOT="${0:a:h}"
source "$SCWRYPTS_ROOT/zsh/common.zsh" || exit 42
#####################################################################
__RUN() {
local USAGE='
Usage : scwrypts [OPTIONS ...] SCRIPT -- [SCRIPT OPTIONS ...]
usage: scwrypts [OPTIONS ...] SCRIPT -- [SCRIPT OPTIONS ...]
OPTIONS
-e, --env <env-name> set environment; overwrites SCWRYPTS_ENV
-n, --no-log skip logging (useful when calling scwrypts as an api)
-l, --list print out command list and exit
-h, --help display this message and exit
'
OPTIONS
-e, --env <env-name> set environment; overwrites SCWRYPTS_ENV
-n, --no-log skip logging (useful when calling scwrypts as an api)
-l, --list print out command list and exit
-h, --help display this message and exit
'
cd "$SCWRYPTS_ROOT"
local ENV_NAME="$SCWRYPTS_ENV"
local SEARCH_PATTERNS=()
local ARGS_ERROR=0
local ERROR=0
while [[ $# -gt 0 ]]
do
case $1 in
-h | --help )
echo $USAGE
__USAGE
return 0
;;
-n | --no-log )
@ -49,7 +50,6 @@ OPTIONS
;;
-* )
__ERROR "unrecognized argument '$1'"
((ARGS_ERROR+=1))
shift 1
;;
* )
@ -59,15 +59,13 @@ OPTIONS
esac
done
[[ $ARGS_ERROR -gt 0 ]] && {
echo $USAGE
return 1
}
__ERROR_CHECK
##########################################
local SCRIPT=$(__SELECT_SCRIPT $SEARCH_PATTERNS)
[ ! $SCRIPT ] && exit 2
export SCWRYPT_NAME=$SCRIPT
local ENV_REQUIRED=$(__CHECK_ENV_REQUIRED && echo 1 || echo 0)
@ -103,7 +101,7 @@ OPTIONS
[ ! $LOGFILE ] && {
[ $HEADER ] && echo $HEADER
[[ $SUBSCWRYPT -eq 0 ]] && {
[ $SUBSCWRYPT ] && {
eval $RUN_STRING $@
exit $?
} || {

View File

@ -1,2 +1,2 @@
#!/bin/zsh
source "${0:a:h}/run"
source "${0:a:h}/run" $@

View File

@ -3,11 +3,11 @@ _DEPENDENCIES+=(
jq
)
_REQUIRED_ENV+=(
_AWS_ACCOUNT
_AWS_PROFILE
_AWS_REGION
AWS_ACCOUNT
AWS_PROFILE
AWS_REGION
)
source ${0:a:h}/../common.zsh
#####################################################################
_AWS() { aws --profile $_AWS_PROFILE --region $_AWS_REGION --output json $@; }
_AWS() { aws --profile $AWS_PROFILE --region $AWS_REGION --output json $@; }

View File

@ -9,6 +9,6 @@ __STATUS "performing AWS ECR docker login"
_AWS ecr get-login-password | docker login \
--username AWS \
--password-stdin \
"$_AWS_ACCOUNT.dkr.ecr.$_AWS_REGION.amazonaws.com" \
&& __SUCCESS "logged in to 'AWS:$_AWS_ACCOUNT:$_AWS_REGION'" \
|| __FAIL 1 "unable to login to '$_AWS_ACCOUNT' in '$_AWS_REGION'"
"$AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com" \
&& __SUCCESS "logged in to 'AWS:$AWS_ACCOUNT:$AWS_REGION'" \
|| __FAIL 1 "unable to login to '$AWS_ACCOUNT' in '$AWS_REGION'"

View File

@ -5,7 +5,7 @@ source ${0:a:h}/../common.zsh
GET_DATABASE_CREDENTIALS() {
local PRINT_PASSWORD=0
local ARGS_ERRORS=0
local ERRORS=0
while [[ $# -gt 0 ]]
do
@ -13,12 +13,13 @@ GET_DATABASE_CREDENTIALS() {
--print-password ) PRINT_PASSWORD=1 ;;
* )
__WARNING "unrecognized argument $1"
ARGS_ERRORS+=1
ERRORS+=1
;;
esac
shift 1
done
[[ $ARGS_ERRORS -ne 0 ]] && return 1
__ERROR_CHECK
##########################################

View File

@ -13,7 +13,7 @@ _ROUTE53_BACKUP() {
for DOMAIN in $(_ROUTE53_GET_DOMAINS)
do
( __STATUS "creating '$BACKUP_PATH/$DOMAIN.txt'" \
&& cli53 export --profile $_AWS_PROFILE $DOMAIN > "$BACKUP_PATH/$DOMAIN.txt" \
&& cli53 export --profile $AWS_PROFILE $DOMAIN > "$BACKUP_PATH/$DOMAIN.txt" \
&& __SUCCESS "backed up '$DOMAIN'" \
|| __ERROR "failed to back up '$DOMAIN'" \
) &
@ -25,7 +25,7 @@ _ROUTE53_BACKUP() {
}
_ROUTE53_GET_DOMAINS() {
cli53 list --profile $_AWS_PROFILE \
cli53 list --profile $AWS_PROFILE \
| awk '{print $2;}' \
| sed '1d; s/\.$//'\
;

13
zsh/config/common.zsh Normal file
View File

@ -0,0 +1,13 @@
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
DEFAULT_CONFIG="${0:a:h}/default.conf.zsh"
source ${0:a:h}/../common.zsh
#####################################################################
SAFE_SYMLINKS=1
# in case config.dotfile.zsh is sourced... allow user to provide initial config ;)
[ ! $CONFIG__USER_SETTINGS ] \
&& CONFIG__USER_SETTINGS="$SCWRYPTS_CONFIG_PATH/config.dotfile.zsh"
[ ! -f "$CONFIG__USER_SETTINGS" ] && cp "$DEFAULT_CONFIG" "$CONFIG__USER_SETTINGS"
source $CONFIG__USER_SETTINGS

View File

@ -0,0 +1,19 @@
#
# scwrypts dot-files config
#
#TERMINFO_PATH=/path/to/sourced/terminfo/files
#
# SAFE_SYMLINKS=1, makes a backup of config files that already exist
# SAFE_SYMLINKS=0, deletes existing config file
#
#SAFE_SYMLINKS=1
# lines which begin with '#' are ignored
SYMLINKS="
# fully qualified path ~/.config/THE-REST
# ---------------------------------------------
# /path/to/your/kitty.conf kitty/kitty.conf
"

6
zsh/config/settings Executable file
View File

@ -0,0 +1,6 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
__EDIT "$CONFIG__USER_SETTINGS"

36
zsh/config/symlinks Executable file
View File

@ -0,0 +1,36 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
SETUP_SYMLINKS() {
while read SYMLINK
do
SETUP_SYMLINK $(echo $SYMLINK | awk '{print $1;}') $(echo $SYMLINK | awk '{print $2}')
done < <(echo $SYMLINKS | sed -n '/^[^#]/p')
}
SETUP_SYMLINK() {
[ ! $2 ] && __FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG'
local SOURCE_CONFIG="$1"
[ ! -f "$SOURCE_CONFIG" ] && __FAIL 2 "no such file '$SOURCE_CONFIG'"
local TARGET_CONFIG="$HOME/.config/$2"
[ ! -d $(dirname "$TARGET_CONFIG") ] && mkdir -p $(dirname "$TARGET_CONFIG")
[ -f "$TARGET_CONFIG" ] && {
[[ $SAFE_SYMLINKS -eq 1 ]] && mv "$TARGET_CONFIG" "$TARGET_CONFIG.bak"
[[ $SAFE_SYMLINKS -eq 0 ]] && rm "$TARGET_CONFIG"
}
ln -s "$SOURCE_CONFIG" "$TARGET_CONFIG" \
&& __SUCCESS "successfully linked '$(basename $(dirname $TARGET_CONFIG))/$(basename $TARGET_CONFIG)'" \
|| __FAIL 3 "failed to create link '$TARGET_CONFIG'" \
;
}
#####################################################################
SETUP_SYMLINKS $@

26
zsh/config/terminfo Executable file
View File

@ -0,0 +1,26 @@
#!/bin/zsh
_DEPENDENCIES+=(
tic
)
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
SETUP_TERMINFO() {
[ ! $TERMINFO_PATH ] && return 0
[ ! -d $TERMINFO_PATH ] && __FAIL 1 "TERMINFO_PATH='$TERMINFO_PATH' does not exist"
local ERRORS=0
for TERMINFO in $(find $TERMINFO_PATH -type f)
do
tic -x $TERMINFO >/dev/null 2>&1 \
&& __SUCCESS "added '$(basename $TERMINFO)'" \
|| __ERROR "failed to add '$(basename $TERMINFO)'" \
;
done
__ERROR_CHECK
}
#####################################################################
SETUP_TERMINFO $@

10
zsh/config/update Executable file
View File

@ -0,0 +1,10 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
__STATUS 'updating all config files and links'
__RUN_SCWRYPT zsh/config/symlinks || exit 1
__RUN_SCWRYPT zsh/config/terminfo || exit 2
__SUCCESS 'finished updating config files and links'

View File

@ -0,0 +1,4 @@
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################

72
zsh/db/run-sql/postgres Executable file
View File

@ -0,0 +1,72 @@
#!/bin/zsh
_DEPENDENCIES+=(
psql
)
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
_RUN_SQL_POSTGRES() {
local _HOST _NAME _PASS _PORT _USER INPUT_FILE
while [[ $# -gt 0 ]]
do
case $1 in
--host | -h ) _HOST="$2"; shift 2 ;;
--name | -d ) _NAME="$2"; shift 2 ;;
--pass | -w ) _PASS="$2"; shift 2 ;;
--port | -p ) _PORT="$2"; shift 2 ;;
--user | -U ) _USER="$2"; shift 2 ;;
--file | -i ) INPUT_FILE="$2"; shift 2 ;;
* ) shift 1 ;;
esac
done
[ ! $_HOST ] && _HOST=127.0.0.1
[ ! $_NAME ] && _NAME=postgres
[ ! $_PORT ] && _PORT=5432
[ ! $_USER ] && _USER=postgres
local SQL_DIR="$SCWRYPTS_DATA_PATH/sql"
[ ! -d $SQL_DIR ] && mkdir -p $SQL_DIR
cd $SQL_DIR
[[ $(ls "*.sql" 2>&1 | wc -l) -eq 0 ]] && {
__ERROR "you haven't made any SQL commands yet"
__REMINDER "add '.sql' files here: '$SQL_DIR/'"
exit 1
}
[ ! $INPUT_FILE ] && INPUT_FILE=$(\
__FZF 'select a sql file to run'
)
[ ! $INPUT_FILE ] && __ABORT
[ ! -f $INPUT_FILE ] && {
__FAIL 2 "no such sql file '$SQL_DIR/$INPUT_FILE'"
}
__STATUS "loading $INPUT_FILE preview..."
_LESS $INPUT_FILE
__STATUS "login : $_USER@$_HOST:$_PORT/$_NAME"
__STATUS "command : ./$INPUT_FILE"
__yN 'run this command?' || __ABORT
__STATUS "running './$INPUT_FILE'"
PGPASSWORD="$_PASS" psql \
-h $_HOST \
-p $_PORT \
-U $_USER \
-d $_NAME \
< $INPUT_FILE \
&& __SUCCESS "finished running './$INPUT_FILE'" \
|| __FAIL 3 "something went wrong running './$INPUT_FILE' (see above)"
}
#####################################################################
__WARNING
__WARNING 'this function is in a beta state'
__WARNING
_RUN_SQL_POSTGRES $@

6
zsh/git/common.zsh Normal file
View File

@ -0,0 +1,6 @@
_DEPENDENCIES+=(
git
)
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################

6
zsh/git/package/build Executable file
View File

@ -0,0 +1,6 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
__RUN_SCWRYPT zsh/git/package/install -- --only-build $@

View File

@ -0,0 +1,74 @@
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################
PACKAGE_INSTALL_DIR="$HOME/.local/share/source-packages"
[ ! -d "$PACKAGE_INSTALL_DIR" ] && mkdir -p "$PACKAGE_INSTALL_DIR"
#####################################################################
CLONE() {
cd "$PACKAGE_INSTALL_DIR"
__STATUS "downloading $NAME"
git clone "$TARGET" "$NAME" \
&& __SUCCESS "successfully downloaded '$NAME'" \
|| __FAIL 1 "failed to download '$NAME'" \
;
}
PULL() {
__STATUS "updating '$NAME'"
cd "$PACKAGE_INSTALL_DIR/$NAME"
git pull origin $(git rev-parse --abbrev-ref HEAD) \
&& __SUCCESS "successfully updated '$NAME'" \
|| __FAIL 1 "failed to update '$NAME'" \
;
}
#####################################################################
BUILD() {
cd "$PACKAGE_INSTALL_DIR/$NAME"
CHECK_MAKE && { MAKE && return 0 || return 1; }
CHECK_MAKEPKG && { MAKEPKG && return 0 || return 2; }
__WARNING 'could not detect supported installation method'
__REMINDER 'complete manual installation in the directory below:'
__REMINDER "$PACKAGE_INSTALL_DIR/$NAME"
}
CHECK_MAKE() { [ -f ./Makefile ]; }
CHECK_MAKEPKG() { [ -f ./PKGBUILD ]; }
MAKE() {
[[ $CLEAN -eq 1 ]] && {
__STATUS "cleaning '$NAME'"
make clean
}
__STATUS "building '$NAME'"
make \
&& __SUCCESS "finished building '$NAME'" \
|| __FAIL 1 "build failed for '$NAME' (see above)"\
;
__STATUS "installing '$NAME'"
__GETSUDO
sudo make install \
&& __SUCCESS "succesfully installed '$NAME'" \
|| __FAIL 2 "failed to install '$NAME' (see above)"\
;
}
MAKEPKG() {
__STATUS "installing '$NAME'"
yes | makepkg -si \
&& __SUCCESS "succesfully installed '$NAME'" \
|| __FAIL 1 "failed to install '$NAME' (see above)"\
;
}
#####################################################################

6
zsh/git/package/download Executable file
View File

@ -0,0 +1,6 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
__RUN_SCWRYPT zsh/git/package/install -- --only-pull $@

88
zsh/git/package/install Executable file
View File

@ -0,0 +1,88 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
INSTALL() {
local USAGE="
usage: [...options...]
options
-t, --target-url <string> target URL; required for first-time download
-n, --local-name <string> local name for package (optional)
-u, --update if package exists, update without prompt
-b, --only-build if package exists, skip update step and only build
-p, --only-pull skip the automated build step
-c, --clean for make, run make clean before build
-h, --help print this message and exit
"
local NAME
local TARGET
local SKIP_BUILD=0
local SKIP_PULL=0
local UPDATE=0
local CLEAN=0
while [[ $# -gt 0 ]]
do
case $1 in
-t | --target-url ) TARGET="$2"; shift 1 ;;
-n | --local-name ) NAME="$2"; shift 1 ;;
-u | --update ) UPDATE=1 ;;
-b | --only-build ) SKIP_PULL=1 ;;
-p | --only-pull ) SKIP_BUILD=1 ;;
-c | --clean ) CLEAN=1 ;;
-h | --help ) __USAGE; exit 0 ;;
-* ) __ERROR "unknown argument '$1'" ;;
* ) [ ! $TARGET ] && TARGET="$1" \
|| __ERROR "extra positional argument '$1'" \
;
;;
esac
shift 1
done
[[ $SKIP_PULL -eq 1 ]] && [[ $SKIP_BUILD -eq 1 ]] && __ERROR 'only one of [-b | -p] can be specified'
[ ! $TARGET ] && [ ! $NAME ] && {
[[ $SKIP_BUILD -eq 1 ]] && {
__ERROR 'cannot skip build without specifying package local-name'
} || {
UPDATE=1
NAME=$(ls "$PACKAGE_INSTALL_DIR" | __FZF 'select a package to update')
[ ! $NAME ] && __ERROR 'target-url required'
}
}
__ERROR_CHECK
####################################################
[ ! $NAME ] && {
NAME=$(echo $TARGET | sed 's/.*\///; s/\.git$//')
__INFO "using default name '$NAME'"
}
[ -d "$PACKAGE_INSTALL_DIR/$NAME" ] && [[ $SKIP_PULL -eq 0 ]] && {
[[ $UPDATE -eq 0 ]] && __Yn "package '$NAME' already exists; update now?" && UPDATE=1
[[ $UPDATE -eq 1 ]] && PULL || return 1
}
[ ! -d "$PACKAGE_INSTALL_DIR/$NAME" ] && {
CLONE || return 2
}
[[ $SKIP_BUILD -eq 1 ]] && return 0
BUILD
}
#####################################################################
INSTALL $@

6
zsh/git/package/update Executable file
View File

@ -0,0 +1,6 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
__RUN_SCWRYPT zsh/git/package/install -- --update $@

31
zsh/latex/build-pdf Executable file
View File

@ -0,0 +1,31 @@
#!/bin/zsh
_DEPENDENCIES+=(
pdflatex
rg
)
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
PDFLATEX() {
[ ! $1 ] && __FAIL 1 'must provide filename'
local FILENAME=$(GET_MAIN_LATEX_FILENAME "$1")
local ARGS=(-interaction=nonstopmode)
ARGS+=("$FILENAME")
cd "$(dirname $FILENAME)"
__STATUS 'running compile (1/2)'
pdflatex ${ARGS[@]} \
|| __FAIL 2 'first compile failed (see above)'
__STATUS 'running compile (2/2)'
pdflatex ${ARGS[@]} >/dev/null 2>&1 \
|| __FAIL 3 'second compile failed :c'
__SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'"
}
#####################################################################
PDFLATEX $@

20
zsh/latex/cleanup Executable file
View File

@ -0,0 +1,20 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
CLEAN_LATEX_LOGFILES() {
local DIRECTORY=$(__GET_PATH_TO_RELATIVE_ARGUMENT ".")
[ $1 ] && DIRECTORY="$(dirname "$(GET_MAIN_LATEX_FILENAME "$1")")"
[ $DIRECTORY ] && [ -d $DIRECTORY ] \
|| __FAIL 1 'unable to parse valid directory'
cd $DIRECTORY
rm $(ls | grep '\.\(aux\)\|\(log\)\|\(pdf\)\|\(out\)\|\(dvi\)$')
__SUCCESS "cleaned up latex artifacts in '$DIRECTORY'"
}
#####################################################################
CLEAN_LATEX_LOGFILES $@

34
zsh/latex/common.zsh Normal file
View File

@ -0,0 +1,34 @@
_DEPENDENCIES+=(
rg
)
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################
GET_MAIN_LATEX_FILENAME() {
local FILENAME=$(__GET_PATH_TO_RELATIVE_ARGUMENT "$1")
local DIRNAME="$FILENAME"
for _ in {1..3}
do
CHECK_IS_MAIN_LATEX_FILE && return 0
DIRNAME="$(dirname "$FILENAME")"
__STATUS "checking '$DIRNAME'"
[[ $DIRNAME =~ ^$HOME$ ]] && break
FILENAME=$(
rg -l --max-depth 1 'documentclass' "$DIRNAME/" \
| grep '\.tex$' \
| head -n1 \
)
__STATUS "here is '$FILENAME'"
done
__WARNING 'unable to find documentclass; pdflatex will probably fail'
echo "$1"
}
CHECK_IS_MAIN_LATEX_FILE() {
[ ! $FILENAME ] && return 1
grep -q 'documentclass' $FILENAME 2>/dev/null && echo $FILENAME || return 3
}

63
zsh/latex/create-new Executable file
View File

@ -0,0 +1,63 @@
#!/bin/zsh
_DEPENDENCIES+=(
pdflatex
rg
)
_REQUIRED_ENV+=()
TEMPLATE_DIR="${0:a:h}/templates"
source ${0:a:h}/common.zsh
#####################################################################
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() {
local DOCUMENT_DIR="$EXECUTION_DIR"
local TEMPLATE=$(GET_TEMPLATES | __FZF 'select a template')
[ ! $TEMPLATE ] && __ABORT
__SUCCESS "selected template '$TEMPLATE'"
__INPUT DOC_TITLE 'document title' || __ABORT
local DOCUMENT_FILE="$DOCUMENT_DIR/$(SLUGIFY_TITLE).tex"
[ -f "$DOCUMENT_FILE" ] && __FAIL 1 "'$(basename $DOCUMENT_FILE)' already exists"
__INPUT DOC_ID 'document id/subtitle'
__INPUT AUTHOR 'author name'
__INPUT AUTHOR_ID 'author id/title'
{
PRINT_TITLE_INFO
cat "$TEMPLATE_DIR/$TEMPLATE/template.tex"
} > "$DOCUMENT_FILE"
cp "$TEMPLATE_DIR/gitignore" "$DOCUMENT_DIR/.gitignore"
for FILE in $(find "$TEMPLATE_DIR/$TEMPLATE" -type f | grep -v '/template.tex$')
do
cp "$FILE" "$DOCUMENT_DIR/" || return 2
done
[[ ! $TEMPLATE =~ ^basic$ ]] \
&& mkdir "$DOCUMENT_DIR/sections" "$DOCUMENT_DIR/graphics"
__SUCCESS "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'"
}
GET_TEMPLATES() {
find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d"
}
PRINT_TITLE_INFO() {
local DATESTRING=$(date '+%B %_d, %Y' | sed 's/ \{1,\}/ /g')
sed "
s^LATEX-DOC-TITLE^$DOC_TITLE^
s^LATEX-DOC-DATE^$DATESTRING^
s^LATEX-DOC-ID^$DOC_ID^
s^LATEX-AUTHOR-NAME^$AUTHOR^
s^LATEX-AUTHOR-ID^$AUTHOR_ID^
" "$TEMPLATE_DIR/main.tex"
}
SLUGIFY_TITLE() {
echo $DOC_TITLE | sed "s^['\"\\/,\!@#\$%^&*()]*^^g; s^\s\+^-^g;"
}
#####################################################################
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE $@

15
zsh/latex/get-pdf Executable file
View File

@ -0,0 +1,15 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
GET_PDF() {
local FILENAME=$(GET_MAIN_LATEX_FILENAME "$1" | sed 's/\.[^.]*$/.pdf/')
[ $FILENAME ] && [ -f $FILENAME ] || __FAIL 1 "no compiled pdf found for '$1'; have you run 'build-pdf'?"
__SUCCESS 'found main pdf'
echo $FILENAME
}
#####################################################################
GET_PDF $@

15
zsh/latex/open-pdf Executable file
View File

@ -0,0 +1,15 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
OPEN_PDF() {
local PDF=$(__RUN_SCWRYPT latex/get-pdf -n -- $1)
[ ! $PDF ] && return 1
__OPEN "$PDF"
}
#####################################################################
OPEN_PDF $@

View File

@ -0,0 +1,37 @@
\usepackage[margin=.75in,bottom=0.5in,top=1.0in]{geometry}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{lastpage}
\newcommand{\headerL} {\documentTitle: \documentDate}
\newcommand{\headerC} {\documentId}
\newcommand{\headerR} {\authorName\ (\authorId)}
\newcommand{\pageOfTotal} {\thepage\ of~\pageref{LastPage}}
\pagestyle{fancy}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[L]{\headerL}\fancyhead[R]{\headerR}\fancyhead[C]{\headerC}
\fancyfoot[C]{\pageOfTotal}
}
\renewcommand{\baselinestretch}{1}
\setlength{\parskip}{0em}
\hyphenpenalty=5000%
\fancyhf{}
\fancyhead[L]{\headerL}\fancyhead[R]{\headerR}\fancyhead[C]{\headerC}
\fancyfoot[C]{\pageOfTotal}
\title{\documentTitle}
\author{\authorName\ \\ \authorId}
\date{\documentDate}
\begin{document}
\maketitle%
% ---------------------------------------------------------------------
% ---------------------------------------------------------------------
\end{document}

View File

@ -0,0 +1,5 @@
*.aux
*.log
*.out
*.pdf
*.dvi

View File

@ -0,0 +1,9 @@
\documentclass[letterpaper]{article}
\newcommand{\documentTitle} {LATEX-DOC-TITLE}
\newcommand{\documentDate} {LATEX-DOC-DATE}
\newcommand{\documentId} {LATEX-DOC-ID}
\newcommand{\authorName} {LATEX-AUTHOR-NAME}
\newcommand{\authorId} {LATEX-AUTHOR-ID}

View File

@ -0,0 +1,11 @@
\ProvidesPackage{code}
% ---------------------------------------------------------------------
\newcommand{\clispsnippet}[2]{%
\lstinputlisting[%
caption=#1,
language=Lisp,
showstringspaces=false,
numbers=left,
]{#2}
}

View File

@ -0,0 +1,46 @@
\ProvidesPackage{formatting}
% ---------------------------------------------------------------------
\newcommand{\headerLeft} {\documentTitle: \documentDate}
\newcommand{\headerCenter} {\documentId}
\newcommand{\headerRight} {\authorName\ (\authorId)}
\newcommand{\pageOfTotal} {\thepage\ of~\pageref{LastPage}}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}{Corollary}[theorem]
\RequirePackage[margin=1in,bottom=.5in,includefoot]{geometry}
\RequirePackage{lastpage}
\RequirePackage{fancyhdr}
% ---------------------------------------------------------------------
% Page 1
\pagestyle{fancy}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[L]{\headerLeft}
\fancyhead[R]{\headerRight}
\fancyhead[C]{\headerCenter}
\fancyfoot[C]{\pageOfTotal}
}
\renewcommand{\baselinestretch}{1}
\setlength{\parskip}{0em}
\setlength{\parindent}{0em}
% ---------------------------------------------------------------------
% Pages 2+
\fancyhf{}
\fancyhead[L]{\headerLeft}
\fancyhead[R]{\headerRight}
\fancyhead[C]{\headerCenter}
\fancyfoot[C]{\pageOfTotal}
% ---------------------------------------------------------------------
\title{\documentTitle}
\author{\authorName\ \\ \authorId}
\date{\documentDate}

View File

View File

@ -0,0 +1,16 @@
\ProvidesPackage{imports}
% ---------------------------------------------------------------------
\RequirePackage{amssymb} % "bold" math letters (e.g. set of integers )
\RequirePackage{amsmath} % advanced math symbols
\RequirePackage{listings} % code snippet styling block
\RequirePackage{tikz} % graphic drawing / generation
\usetikzlibrary{arrows,automata}
\usetikzlibrary{trees}
\RequirePackage{graphicx} % include images
\graphicspath{{./graphics/}}
\RequirePackage[english]{babel} % -- English compilation rules

View File

@ -0,0 +1,13 @@
\ProvidesPackage{shorthand}
% ---------------------------------------------------------------------
\newcommand{\egfcoefficient}{\ensuremath{\left[\frac{x^n}{n!}\right]}}
\newcommand{\ogfcoefficient}{\ensuremath{\left[x^n\right]}}
\newcommand{\falling}[1]{^{\underline{#1}}}
\newcommand{\divides}{\ensuremath{\;\backslash\;}}
\newcommand{\sumgz}{\ensuremath{\sum_{n\geq 0}}}
\newcommand{\sumdiv}{\ensuremath{\sum_{d\divides n}}}
\newcommand{\union}{\ensuremath{\cup}}
\newcommand{\intersect}{\ensuremath{\cap}}

View File

@ -0,0 +1,12 @@
\usepackage{imports}
\usepackage{formatting}
\usepackage{shorthand}
\usepackage{code}
\begin{document}
\maketitle
% ---------------------------------------------------------------------
% \input{sections/01.introduction.tex}
% \includegraphic{graphics/diagram-a.png}
% ---------------------------------------------------------------------
\end{document}

View File

@ -0,0 +1,7 @@
\ProvidesPackage{custom-headers}
% ---------------------------------------------------------------------
\newcommand{\firstH}[1] {\begin{large}\textbf{#1}\end{large}\par}
\newcommand{\secondH}[1] {\textbf{#1}\par}
\newcommand{\thirdH}[1] {\textbf{#1}. }
\newcommand{\fourthH}[1] {\textbf{\textit{#1}}. }

View File

@ -0,0 +1,31 @@
\ProvidesPackage{formatting}
% ---------------------------------------------------------------------
\newcommand{\horizontalHeader} {%
\authorName\hfill
\authorId\hfill
\documentId\hfill
\documentDate%
}
\RequirePackage[margin=1in]{geometry}
\RequirePackage{fancyhdr}
% ---------------------------------------------------------------------
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[C]{\horizontalHeader}
\fancyfoot[C]{\thepage}
\renewcommand{\baselinestretch}{1}
\setlength{\parskip}{1em}
\setlength{\parindent}{0em}
\raggedright%
% ---------------------------------------------------------------------
\newcommand{\insertTitle} {%
\centerline{\begin{large}\textbf{\documentTitle}\end{large}}
}

View File

@ -0,0 +1,11 @@
\ProvidesPackage{imports}
% ---------------------------------------------------------------------
\RequirePackage{times} % "Times New Roman" font
\RequirePackage{kantlipsum} % generate Kantian lorem ipsum
\RequirePackage{graphicx} % include images
\graphicspath{{./graphics/}}
\RequirePackage[english]{babel} % -- English compilation rules

View File

@ -0,0 +1,15 @@
\usepackage{imports}
\usepackage{formatting}
\usepackage{custom-headers}
\begin{document}
\insertTitle%
% ---------------------------------------------------------------------
% \input{sections/abstract.tex}
% \includgraphics{graphics/table-a.png}
\firstH{First-level Header}
\kant%
% ---------------------------------------------------------------------
\end{document}

19
zsh/memo/common.zsh Normal file
View File

@ -0,0 +1,19 @@
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################
set +o noglob
MEMO__FILETYPE=md
MEMO__DIR="$SCWRYPTS_DATA_PATH/memo"
[ ! -d $MEMO__DIR ] && mkdir -p $MEMO__DIR
LIST_MEMOS() { ls $MEMO__DIR | sed "s/\.$MEMO__FILETYPE$//" | sort; }
# TODO : remove deprecated migration
[ -d $HOME/.memos ] && {
__Yn 'detected legacy memos folder; upgrade now?' && {
mv $HOME/.memos/* $MEMO__DIR
rmdir "$HOME/.memos"
}
}

30
zsh/memo/open Executable file
View File

@ -0,0 +1,30 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
OPEN_MEMO() {
local MEMO_NAME=$(LIST_MEMOS | __FZF_TAIL 'select/create a memo')
[ ! "$MEMO_NAME" ] && __ABORT
MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
[ ! -f $MEMO_FILE ] && {
__STATUS "creating memo '$MEMO_NAME'"
echo "# $MEMO_NAME" > "$MEMO_FILE" \
&& __SUCCESS "created memo '$MEMO_NAME'" \
|| __FAIL 1 "failed to create '$MEMO_FILE'" \
;
}
DATESTRING="## $(date '+%A, %B %-d, %Y')"
grep -q "$DATESTRING" "$MEMO_FILE" || echo "$DATESTRING" >> "$MEMO_FILE"
__EDIT "$MEMO_FILE"
}
#####################################################################
OPEN_MEMO $@

32
zsh/memo/remove Executable file
View File

@ -0,0 +1,32 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
OPEN_MEMO() {
local MEMO_NAME=$(LIST_MEMOS | __FZF 'select a memo to delete')
local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
[ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || __ABORT
__STATUS "--- START OF MEMO ---------------------------------------------------"
cat "$MEMO_FILE"
__STATUS "--- END OF MEMO -----------------------------------------------------"
__WARNING
__WARNING 'memos are not backed up by default; deletion is permanent!'
__WARNING
__yN 'are you sure you want to delete this memo?' || __ABORT
__STATUS "deleting memo '$MEMO_FILE'"
rm "$MEMO_FILE" \
&& __SUCCESS "removed memo '$MEMO_NAME'" \
|| __FAIL 1 "failed to remove memo '$MEMO_NAME'" \
;
}
#####################################################################
OPEN_MEMO $@

View File

@ -29,9 +29,7 @@ source ${0:a:h}/common.zsh
__REMINDER '(equivalent to "npm install" or "pip install -r requirements.txt")'
__REMINDER
} || {
__STATUS 'opening local config for editing'
__EDIT $SCWRYPTS_CONFIG_PATH/config
__STATUS 'finished editing!'
}

View File

@ -6,6 +6,7 @@ source ${0:a:h}/../common.zsh
_SORT_ENV() {
local ENV_FILE="$1"
sed -i "/^# /d; /^$/d" "$ENV_FILE"
sed -i "s/^[A-Z]/export &/; s/^[^#=]\\+$/&=/" "$ENV_FILE"
LC_COLLATE=C sort -uo "$ENV_FILE" "$ENV_FILE"
}

View File

@ -17,16 +17,14 @@ ENV_FILE=$(__GET_ENV_FILE $ENV_NAME)
[ ! -f $ENV_FILE ] && {
__STATUS "Creating '$ENV_NAME'..." \
&& cp $__ENV_TEMPLATE $ENV_FILE \
&& __SUCCESS 'created!' \
&& __RUN_SCWRYPT zsh/scwrypts/environment/synchronize -- --no-prompt \
&& __SUCCESS "created '$ENV_NAME'" \
|| { __ERROR "failed to create '$ENV_FILE'"; exit 1; }
}
__STATUS "opening '$ENV_NAME' for editing..."
__EDIT $ENV_FILE
sed -i "s/^[A-Z]/export &/; s/^[^#=]\\+$/&=/" $ENV_FILE
LC_COLLATE=C sort -uo $ENV_FILE $ENV_FILE
_SORT_ENV $ENV_FILE
__STATUS "finished editing; looking for new environment variables"
while read line
do
ENV_VAR=$(echo "$line" | sed 's/=.*$//; s/^export //')

View File

@ -27,6 +27,7 @@ _SYNCHRONIZE() {
_INSERT_NEW_VARIABLES
_REMOVE_OLD_VARIABLES
_SORT_AND_CASCADE
_ADD_DESCRIPTIONS
__SUCCESS 'finished sync!'
}
@ -126,5 +127,27 @@ _CASCADE_ENVIRONMENT() {
__SUCCESS "finished '$PARENT_NAME' propagation"
}
_ADD_DESCRIPTIONS() {
__STATUS 'updating descriptions'
while read DESCRIPTION_LINE
do
ENV_VAR=$(echo $DESCRIPTION_LINE | sed 's/ \+| .*$//')
DESCRIPTION=$(echo $DESCRIPTION_LINE | sed 's/^.* | //')
for ENV_NAME in $(echo $ENVIRONMENTS)
do
sed -i "/^export $ENV_VAR=/i # $DESCRIPTION" "$(__GET_ENV_FILE $ENV_NAME)"
done
done < <(sed -n '/^[^ ]\+ \+| /p' "$__ENV_TEMPLATE.descriptions")
while read ENV_VAR
do
for ENV_NAME in $(echo $ENVIRONMENTS)
do
sed -i "/^export $ENV_VAR=/a \ " "$(__GET_ENV_FILE $ENV_NAME)"
sed -i "s/^ $//" "$(__GET_ENV_FILE $ENV_NAME)"
done
done < <(grep -B1 '^$' "$__ENV_TEMPLATE.descriptions" | grep '|' | awk '{print $1;}')
}
#####################################################################
_SYNCHRONIZE $@

View File

@ -23,3 +23,22 @@ __WHITE='\033[1;37m'
__LIGHT_GRAY='\033[0;37m'
__COLOR_RESET='\033[0m'
__GET_RANDOM_COLOR() {
local COLORS=(
$__RED
$__LIGHT_RED
$__GREEN
$__LIGHT_GREEN
$__ORANGE
$__YELLOW
$__BLUE
$__DARK_BLUE
$__PURPLE
$__DARK_PURPLE
$__CYAN
$__DARK_CYAN
$__WHITE
)
print "$__COLOR_RESET${COLORS[$(shuf -i 1-${#COLORS[@]} -n 1)]}"
}

View File

@ -3,6 +3,7 @@ __CREDITS() {
[ ! $SCWRYPTS_ROOT ] && return 0
local COMMAND="$1"
[[ $COMMAND =~ - ]] && COMMAND=$(echo $COMMAND | sed 's/-/--/g')
cd $SCWRYPTS_ROOT
cat ./**/README.md \
| grep 'Generic Badge' \

View File

@ -17,7 +17,7 @@ __CHECK_DEPENDENCY() {
}
__CHECK_COREUTILS() {
local COREUTILS=(awk find grep sed)
local COREUTILS=(awk find grep sed readlink)
local MISSING_DEPENDENCY_COUNT=0
local NON_GNU_DEPENDENCY_COUNT=0

View File

@ -8,7 +8,7 @@ __PRINT() {
printf "${COLOR}${MESSAGE}${__COLOR_RESET}${LINE_END}"
}
__ERROR() { __PRINT $__RED "ERROR ✖ : $@" >&2; }
__ERROR() { __PRINT $__RED "ERROR ✖ : $@" >&2; ((ERRORS+=1)); }
__SUCCESS() { __PRINT $__GREEN "SUCCESS ✔ : $@" >&2; }
__WARNING() { __PRINT $__ORANGE "WARNING  : $@" >&2; }
__STATUS() { __PRINT $__BLUE "STATUS : $@" >&2; }
@ -23,6 +23,35 @@ __PROMPT() {
__FAIL() { __ERROR "${@:2}"; exit $1; }
__ABORT() { __FAIL 69 'user abort'; }
__ERROR_CHECK() {
[ ! $ERRORS ] && ERRORS=0
[[ $ERRORS -ne 0 ]] && __USAGE
[[ $ERRORS -eq 0 ]] || exit $ERRORS
}
__USAGE() {
[ ! $USAGE ] && return 0
USAGE=$(echo $USAGE | sed "s/^\t\+//; s/\s\+$//")
local USAGE_LINE=$(\
echo $USAGE \
| grep -i '^ *usage *:' \
| sed "s;^[^:]*:;& scwrypts -- $SCWRYPT_NAME;" \
| sed 's/ \{2,\}/ /g; s/scwrypts -- scwrypts/scwrypts/' \
)
local THE_REST=$(echo $USAGE | grep -vi '^ *usage *:' | sed 'N;/^\n$/D;P;D;')
{ echo; __PRINT $__DARK_BLUE "$USAGE_LINE"; echo $THE_REST; echo } >&2
}
__INPUT() {
__PROMPT "${@:2}"
__READ $1
local VALUE=$(eval echo '$'$1)
[ $VALUE ]
}
__Yn() {
__PROMPT "$@ [Yn]"
[ $CI ] && { echo y; return 0; }
@ -74,5 +103,8 @@ __EDIT() {
__ERROR 'currently in CI, but __EDIT explicitly requires terminal input'
return 1
}
__STATUS "opening '$1' for editing"
$EDITOR $@ </dev/tty >/dev/tty
__SUCCESS "finished editing '$1'!"
}

View File

@ -14,12 +14,6 @@ source ${0:a:h}/credits.zsh
IMPORT_ERROR=0
[ $CI ] && {
export _AWS_PROFILE="$AWS_PROFILE"
export _AWS_ACCOUNT="$AWS_ACCOUNT"
export _AWS_REGION="$AWS_REGION"
}
source ${0:a:h}/dependencies.zsh
_DEP_ERROR=0
_DEPENDENCIES=($(echo $_DEPENDENCIES | sort -u))

8
zsh/vim/common.zsh Normal file
View File

@ -0,0 +1,8 @@
_DEPENDENCIES+=(
vim
)
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################
_VIM() { vim $@ </dev/tty >/dev/tty; }

49
zsh/vim/vundle/common.zsh Normal file
View File

@ -0,0 +1,49 @@
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/../common.zsh
#####################################################################
VUNDLE_PLUGIN_DIR="$HOME/.vim/bundle"
VUNDLE_BUILD_DEFINITIONS="$VUNDLE_PLUGIN_DIR/build.zsh"
[ ! -f $VUNDLE_BUILD_DEFINITIONS ] && {
{
echo -e "#\n# Scwrypts Build Definitions\n#\n"
} > $VUNDLE_BUILD_DEFINITIONS
}
VUNDLE_PLUGIN_LIST=$(ls $VUNDLE_PLUGIN_DIR | grep -v 'Vundle.vim' | grep -v 'build.zsh')
source $VUNDLE_BUILD_DEFINITIONS
for PLUGIN in $(echo $VUNDLE_PLUGIN_LIST)
do
typeset -f VUNDLE_BUILD__$PLUGIN >/dev/null 2>/dev/null || {
echo -e "\nVUNDLE_BUILD__$PLUGIN() {\n # ... build steps from $HOME/.vim/$PLUGIN \n}" \
>> $VUNDLE_BUILD_DEFINITIONS
VUNDLE_BUILD__$PLUGIN() {}
}
done
#####################################################################
VUNDLE_PLUGIN_INSTALL() {
_VIM +PluginInstall +qall \
&& __SUCCESS 'successfully installed Vundle.vim plugins' \
|| __FAIL 1 'failed to install Vundle.vim plugins'
}
VUNDLE_REBUILD_PLUGINS() {
local ERRORS=0
local PLUGIN
for PLUGIN in $(echo $VUNDLE_PLUGIN_LIST)
do
cd "$VUNDLE_PLUGIN_DIR/$PLUGIN"
__STATUS "building '$PLUGIN'"
VUNDLE_BUILD__$PLUGIN \
&& __SUCCESS "finished building '$PLUGIN'" \
|| __ERROR "failed to build '$PLUGIN' (see above)" \
;
done
return $ERRORS
}

View File

@ -0,0 +1,6 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
__EDIT "$VUNDLE_BUILD_DEFINITIONS"

13
zsh/vim/vundle/install Executable file
View File

@ -0,0 +1,13 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
PLUGIN_INSTALL() {
VUNDLE_PLUGIN_INSTALL || return 1
VUNDLE_REBUILD_PLUGINS || return 2
}
#####################################################################
PLUGIN_INSTALL $@

6
zsh/vim/vundle/rebuild Executable file
View File

@ -0,0 +1,6 @@
#!/bin/zsh
_DEPENDENCIES+=()
_REQUIRED_ENV+=()
source ${0:a:h}/common.zsh
#####################################################################
VUNDLE_REBUILD_PLUGINS $@