Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
22dd6f8112 | |||
710d42e248 | |||
244c188deb | |||
5c882597da | |||
4047aad29e | |||
6333a2f6b8 |
@ -1,10 +1,14 @@
|
||||
#!/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 I3__BORDER_PIXEL_SIZE=
|
||||
export I3__DMENU_FONT_SIZE=
|
||||
export I3__GLOBAL_FONT_SIZE=
|
||||
export I3__MODEL_CONFIG=
|
||||
export REDIS_AUTH=
|
||||
export REDIS_HOST=
|
||||
export REDIS_PORT=
|
||||
export _AWS_ACCOUNT=
|
||||
export _AWS_PROFILE=
|
||||
export _AWS_REGION=
|
||||
|
17
.env.template.descriptions
Normal file
17
.env.template.descriptions
Normal file
@ -0,0 +1,17 @@
|
||||
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 |
|
||||
|
||||
I3__BORDER_PIXEL_SIZE | custom i3 configuration settings
|
||||
I3__DMENU_FONT_SIZE |
|
||||
I3__GLOBAL_FONT_SIZE |
|
||||
I3__MODEL_CONFIG |
|
||||
|
||||
REDIS_AUTH | redis connection credentials
|
||||
REDIS_HOST |
|
||||
REDIS_PORT |
|
@ -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
|
||||
|
@ -28,14 +28,14 @@ __GET_PATH_TO_RELATIVE_ARGUMENT() {
|
||||
__RUN_SCWRYPT() {
|
||||
((SUBSCWRYPT+=1))
|
||||
{ printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "; } >&2
|
||||
echo " BEGIN SUBSCWRYPT : $(basename $1)" >&2
|
||||
echo " BEGIN SUBSCWRYPT : $@" >&2
|
||||
|
||||
SUBSCWRYPT=$SUBSCWRYPT SCWRYPTS_ENV=$ENV_NAME \
|
||||
"$SCWRYPTS_ROOT/scwrypts" $@
|
||||
EXIT_CODE=$?
|
||||
|
||||
{ printf ' '; printf '--%.0s' {1..$SUBSCWRYPT}; printf " ($SUBSCWRYPT) "; } >&2
|
||||
echo " END SUBSCWRYPT : $(basename $1)" >&2
|
||||
echo " END SUBSCWRYPT : $1" >&2
|
||||
((SUBSCWRYPT-=1))
|
||||
|
||||
return $EXIT_CODE
|
||||
|
17
run
17
run
@ -7,27 +7,27 @@ source "$SCWRYPTS_ROOT/zsh/common.zsh" || exit 42
|
||||
|
||||
__RUN() {
|
||||
local USAGE='
|
||||
Usage : scwrypts [OPTIONS ...] SCRIPT -- [SCRIPT OPTIONS ...]
|
||||
usage: scwrypts [OPTIONS ...] SCRIPT -- [SCRIPT OPTIONS ...]
|
||||
|
||||
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
|
||||
'
|
||||
'
|
||||
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 )
|
||||
@ -50,7 +50,6 @@ OPTIONS
|
||||
;;
|
||||
-* )
|
||||
__ERROR "unrecognized argument '$1'"
|
||||
((ARGS_ERROR+=1))
|
||||
shift 1
|
||||
;;
|
||||
* )
|
||||
@ -60,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)
|
||||
|
||||
|
@ -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 $@; }
|
||||
|
@ -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'"
|
||||
|
@ -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
|
||||
|
||||
##########################################
|
||||
|
||||
|
@ -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/\.$//'\
|
||||
;
|
||||
|
@ -6,7 +6,7 @@ source ${0:a:h}/utils/utils.module.zsh \
|
||||
|
||||
#####################################################################
|
||||
|
||||
__GET_ENV_FILES() { find $SCWRYPTS_CONFIG_PATH/env -maxdepth 1 -type f | sort -r }
|
||||
__GET_ENV_FILES() { ls $SCWRYPTS_CONFIG_PATH/env | sort -r }
|
||||
[ ! "$(__GET_ENV_FILES)" ] && {
|
||||
cp $__ENV_TEMPLATE "$SCWRYPTS_CONFIG_PATH/env/dev"
|
||||
cp $__ENV_TEMPLATE "$SCWRYPTS_CONFIG_PATH/env/local"
|
||||
|
14
zsh/config/common.zsh
Normal file
14
zsh/config/common.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
_DEPENDENCIES+=()
|
||||
_REQUIRED_ENV+=()
|
||||
DEFAULT_CONFIG="${0:a:h}/default.conf.zsh"
|
||||
source ${0:a:h}/../common.zsh
|
||||
#####################################################################
|
||||
|
||||
SAFE_SYMLINKS=1
|
||||
|
||||
# in case dotfiles.zsh is sourced... allow user to provide initial config ;)
|
||||
[ ! $CONFIG__USER_SETTINGS ] \
|
||||
&& CONFIG__USER_SETTINGS="$SCWRYPTS_CONFIG_PATH/dotfiles.zsh"
|
||||
|
||||
[ ! -f "$CONFIG__USER_SETTINGS" ] && cp "$DEFAULT_CONFIG" "$CONFIG__USER_SETTINGS"
|
||||
source $CONFIG__USER_SETTINGS
|
19
zsh/config/default.conf.zsh
Normal file
19
zsh/config/default.conf.zsh
Normal 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
6
zsh/config/settings
Executable 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
36
zsh/config/symlinks
Executable 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" ] && [ ! -d "$SOURCE_CONFIG" ] && __FAIL 2 "no such file or directory '$SOURCE_CONFIG'"
|
||||
|
||||
local TARGET_CONFIG="$HOME/.config/$2"
|
||||
|
||||
[ ! -d $(dirname "$TARGET_CONFIG") ] && mkdir -p $(dirname "$TARGET_CONFIG")
|
||||
|
||||
[[ $SAFE_SYMLINKS -eq 1 ]] \
|
||||
&& mv "$TARGET_CONFIG" "$TARGET_CONFIG.bak" >/dev/null 2>&1
|
||||
|
||||
rm "$TARGET_CONFIG" >/dev/null 2>&1
|
||||
|
||||
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
26
zsh/config/terminfo
Executable 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
10
zsh/config/update
Executable 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'
|
6
zsh/git/common.zsh
Normal file
6
zsh/git/common.zsh
Normal file
@ -0,0 +1,6 @@
|
||||
_DEPENDENCIES+=(
|
||||
git
|
||||
)
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/../common.zsh
|
||||
#####################################################################
|
6
zsh/git/package/build
Executable file
6
zsh/git/package/build
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/zsh
|
||||
_DEPENDENCIES+=()
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/common.zsh
|
||||
#####################################################################
|
||||
__RUN_SCWRYPT zsh/git/package/install -- --only-build $@
|
74
zsh/git/package/common.zsh
Normal file
74
zsh/git/package/common.zsh
Normal 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
6
zsh/git/package/download
Executable 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
88
zsh/git/package/install
Executable 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
6
zsh/git/package/update
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/zsh
|
||||
_DEPENDENCIES+=()
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/common.zsh
|
||||
#####################################################################
|
||||
__RUN_SCWRYPT zsh/git/package/install -- --update $@
|
14
zsh/i3/common.zsh
Normal file
14
zsh/i3/common.zsh
Normal file
@ -0,0 +1,14 @@
|
||||
_DEPENDENCIES+=(
|
||||
i3
|
||||
i3-msg
|
||||
)
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/../common.zsh
|
||||
#####################################################################
|
||||
|
||||
[ ! $DISPLAY ] && export DISPLAY=:0
|
||||
|
||||
_NOTIFY() {
|
||||
__CHECK_DEPENDENCY notify-send || return 0
|
||||
notify-send "SCWRYPTS $SCWRYPT_NAME" $@
|
||||
}
|
105
zsh/i3/create-local-font-override
Executable file
105
zsh/i3/create-local-font-override
Executable file
@ -0,0 +1,105 @@
|
||||
#!/bin/zsh
|
||||
_DEPENDENCIES+=(
|
||||
diff
|
||||
)
|
||||
_REQUIRED_ENV+=(
|
||||
I3__MODEL_CONFIG
|
||||
)
|
||||
source ${0:a:h}/common.zsh
|
||||
|
||||
__CHECK_ENV_VAR I3__GLOBAL_FONT_SIZE --optional
|
||||
__CHECK_ENV_VAR I3__DMENU_FONT_SIZE --optional
|
||||
__CHECK_ENV_VAR I3__BORDER_PIXEL_SIZE --optional
|
||||
#####################################################################
|
||||
|
||||
REGEX_FONT='^\(font [^0-9]*\)\(.*\)'
|
||||
REGEX_DMENU="^\\(.*dmenu_run .*-fn '[^0-9]*\\)\\([0-9]*\\)'"
|
||||
REGEX_BORDER='^\(for_window.*border pixel \)\(.*\)'
|
||||
|
||||
INSTALL() {
|
||||
local USAGE="
|
||||
usage: [...options...]
|
||||
|
||||
options
|
||||
-f, --force force replacement of existing i3config
|
||||
-n, --no-link if output config and template are the same, don't create link
|
||||
|
||||
-h, --help print this message and exit
|
||||
|
||||
environment
|
||||
I3__MODEL_CONFIG fully-qualified path to sourced i3config
|
||||
I3__GLOBAL_FONT_SIZE global font size
|
||||
I3__DMENU_FONT_SIZE (optional) font size for 'dmenu' command
|
||||
I3__BORDER_PIXEL_SIZE (optional) pixel-width of window borders
|
||||
|
||||
I3 provides no way to include dynamic variables in your config.
|
||||
The main difference I want between my i3 configurations is font-size
|
||||
to match the current monitor. Since i3-msg provides no way to change
|
||||
font size, I run this command to update those variables on a local
|
||||
copy of my sourced config
|
||||
"
|
||||
local FORCE=0
|
||||
local AUTOLINK=1
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-f | --force ) FORCE=1 ;;
|
||||
-n | --no-link ) AUTOLINK=0 ;;
|
||||
-h | --help ) __USAGE; exit 0 ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
__STATUS 'reading local i3config'
|
||||
[[ ^$I3__MODEL_CONFIG$ =~ ^$HOME/.config/i3/config$ ]] && {
|
||||
__STATUS "model configuration is default configuration"
|
||||
I3__MODEL_CONFIG="$I3__MODEL_CONFIG.template"
|
||||
[ ! -f "$I3__MODEL_CONFIG" ] && {
|
||||
__STATUS "creating template"
|
||||
cp "$HOME/.config/i3/config" "$I3__MODEL_CONFIG.template"
|
||||
}
|
||||
__STATUS "referring to '$I3__MODEL_CONFIG'"
|
||||
}
|
||||
local CONFIG=$(cat "$I3__MODEL_CONFIG")
|
||||
[ ! $CONFIG ] && __FAIL 1 "failed to read config at '$I3__MODEL_CONFIG'"
|
||||
|
||||
local CONFIG_FILE="$HOME/.config/i3/config"
|
||||
[ ! -d $(dirname "$CONFIG_FILE") ] && mkdir -p "$(dirname "$CONFIG_FILE")"
|
||||
|
||||
[ -f "$CONFIG_FILE" ] && mv "$CONFIG_FILE" "$CONFIG_FILE.bak"
|
||||
|
||||
[ $I3__GLOBAL_FONT_SIZE ] && {
|
||||
__STATUS "setting global font size to '$I3__DMENU_FONT_SIZE'"
|
||||
CONFIG=$(echo $CONFIG | sed "s/$REGEX_FONT/\\1$I3__GLOBAL_FONT_SIZE/")
|
||||
}
|
||||
|
||||
[ $I3__DMENU_FONT_SIZE ] && {
|
||||
__STATUS "setting dmenu font size to '$I3__DMENU_FONT_SIZE'"
|
||||
CONFIG=$(echo $CONFIG | sed "s/$REGEX_DMENU/\\1$I3__DMENU_FONT_SIZE/")
|
||||
}
|
||||
|
||||
[ $I3__BORDER_PIXEL_SIZE ] && {
|
||||
__STATUS "setting border pixel size to '$I3__BORDER_PIXEL_SIZE'"
|
||||
CONFIG=$(echo $CONFIG | sed "s/$REGEX_BORDER/\\1$I3__BORDER_PIXEL_SIZE/")
|
||||
}
|
||||
|
||||
echo $CONFIG > "$CONFIG_FILE"
|
||||
[ -f "$CONFIG_FILE.bak" ] \
|
||||
&& diff "$CONFIG_FILE" "$CONFIG_FILE.bak" -q >/dev/null \
|
||||
&& mv "$CONFIG_FILE.bak" "$CONFIG_FILE" \
|
||||
&& __INFO "no changes were made" \
|
||||
;
|
||||
|
||||
[[ $AUTOLINK -eq 1 ]] \
|
||||
&& diff "$CONFIG_FILE" "$I3__MODEL_CONFIG" -q >/dev/null \
|
||||
&& rm "$CONFIG_FILE" \
|
||||
&& ln -s "$I3__MODEL_CONFIG" "$CONFIG_FILE" \
|
||||
&& __INFO "output is the same as model, i3config has been linked to model" \
|
||||
;
|
||||
|
||||
[[ $FORCE -eq 1 ]] && rm "$CONFIG.bak" >/dev/null 2>&1
|
||||
return 0
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
INSTALL $@
|
113
zsh/i3/launch-or-show
Executable file
113
zsh/i3/launch-or-show
Executable file
@ -0,0 +1,113 @@
|
||||
#!/bin/zsh
|
||||
_DEPENDENCIES+=(
|
||||
xdotool
|
||||
xrandr
|
||||
i3-msg
|
||||
)
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/common.zsh
|
||||
#####################################################################
|
||||
|
||||
LAUNCH_OR_SHOW() {
|
||||
local USAGE="
|
||||
usage: <path-executable> [client-class] [...options...]
|
||||
|
||||
options
|
||||
-c, --client <string> if different from the executable name, xprop CLIENT_CLASS
|
||||
|
||||
-s, --scale <value> (default: 0.8 or 0.5 if screen width >3000px)
|
||||
-x, --x-offset <value> (default: 0.0)
|
||||
-y, --y-offset <value> (default: 0.0)
|
||||
|
||||
-a, --always-launch invoke executable even if client-class exists
|
||||
-n, --no-resize don't resize the window (ignores -sxy flags)
|
||||
|
||||
-h, --help print this message and exit
|
||||
|
||||
Makes it easy to bind appications to key shortcuts without having to
|
||||
spin up redundant instances or cycle through the scratchpad queue.
|
||||
|
||||
Depending on state, performs one of three useful functions
|
||||
1) starts application
|
||||
2) adds application window to the scratchpad
|
||||
3) pulls applciation from scratchpad to foreground on active screen
|
||||
"
|
||||
local APPLICATION CLIENT_CLASS
|
||||
|
||||
local XFFSET=0.0
|
||||
local YFFSET=0.0
|
||||
local SCALE=0.8
|
||||
[[ $(xrandr | grep primary | awk '{print $4;}' | sed 's/x.*//') -gt 3000 ]] \
|
||||
&& SCALE=0.5
|
||||
|
||||
local ALWAYS_LAUNCH=0
|
||||
local RESIZE=1
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-c | --client ) CLIENT_CLASS="$2"; shift 1 ;;
|
||||
-x | --x-offset ) XFFSET=$2; shift 1 ;;
|
||||
-y | --y-offset ) YFFSET=$2; shift 1 ;;
|
||||
-s | --scale ) SCALE=$2; shift 1 ;;
|
||||
|
||||
-a | --always-launch ) ALWAYS_LAUNCH=1 ;;
|
||||
-n | --no-resize ) RESIZE=0 ;;
|
||||
|
||||
-h | --help ) __USAGE; exit 0 ;;
|
||||
|
||||
* )
|
||||
[ ! $APPLICATION ] && APPLICATION="$1" \
|
||||
|| __ERROR "extra positional argument '$1'"
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ ! $APPLICATION ] && __ERROR 'path-executable required'
|
||||
[ ! $CLIENT_CLASS ] && CLIENT_CLASS=$APPLICATION
|
||||
|
||||
[ $APPLICATION ] && {
|
||||
__CHECK_DEPENDENCY $APPLICATION || {
|
||||
__ERROR "$APPLICATION is not installed"
|
||||
_NOTIFY "ERROR: $APPLICATION not found"
|
||||
}
|
||||
}
|
||||
|
||||
__ERROR_CHECK
|
||||
|
||||
local LAUNCH_APP=$ALWAYS_LAUNCH
|
||||
__STATUS "looking for window process ids"
|
||||
xdotool search --class $CLIENT_CLASS || LAUNCH_APP=1
|
||||
|
||||
[[ $LAUNCH_APP -eq 1 ]] && {
|
||||
__STATUS 'launching application'
|
||||
i3-msg "exec --no-startup-id $APPLICATION;"
|
||||
sleep .5
|
||||
}
|
||||
|
||||
__STATUS 'getting target window size'
|
||||
WINDOW_SIZE=$(\
|
||||
xrandr \
|
||||
| grep 'connected primary' \
|
||||
| sed 's/.*connected primary \([^x]*\)x\([^+]*\).*/\1 \2/' \
|
||||
| awk -v f=$SCALE -v x=$XFFSET -v y=$YFFSET \
|
||||
'{print int($1*f+x)," ",int($2*f+y);}'\
|
||||
)
|
||||
__INFO "window size: $WINDOW_SIZE"
|
||||
|
||||
__STATUS 'moving window to scratchpad'
|
||||
i3-msg "[class=$CLIENT_CLASS] move scratchpad"
|
||||
|
||||
[[ $RESIZE -eq 1 ]] \
|
||||
&& __STATUS 'resizing window' \
|
||||
&& i3-msg "[class=$CLIENT_CLASS] resize set $WINDOW_SIZE"
|
||||
|
||||
__STATUS 'pulling window from scratchpad to foreground'
|
||||
i3-msg "[class=$CLIENT_CLASS] scratchpad show"
|
||||
|
||||
__STATUS 'moving window to center of current screen'
|
||||
i3-msg "[class=$CLIENT_CLASS] move position center"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
LAUNCH_OR_SHOW $@
|
@ -21,9 +21,7 @@ OPEN_MEMO() {
|
||||
DATESTRING="## $(date '+%A, %B %-d, %Y')"
|
||||
grep -q "$DATESTRING" "$MEMO_FILE" || echo "$DATESTRING" >> "$MEMO_FILE"
|
||||
|
||||
__STATUS "opening memo '$MEMO_NAME' for editing"
|
||||
__EDIT "$MEMO_FILE"
|
||||
__SUCCESS "finished editing memo '$MEMO_NAME'"
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,26 @@ Inherited values are denoted by `# inherited from <parent-name>` in the environm
|
||||
|
||||
Nested children will inherit values from all parents.
|
||||
|
||||
### Special Environment Variable Syntax
|
||||
|
||||
All environment variables which end in `__[a-z_]+` are ignored by the template file.
|
||||
These environment variables *will propagate to children*, but will not be removed nor staged into the `.env.template`.
|
||||
|
||||
#### `__select` Environment Variables
|
||||
Omit any variable, but provide a comma-separated list with the `__select` suffix, and the user will be prompted to select a value from the provided options.
|
||||
|
||||
In the following configuration, the user will be prompted to select an `AWS_REGION` once at the beginning of scwrypt execution:
|
||||
|
||||
```zsh
|
||||
export AWS_REGION=
|
||||
export AWS_REGION__select=us-east-1,us-east-2,us-west-1,us-west-2
|
||||
```
|
||||
|
||||
Setting the `AWS_REGION` variable will cause scwrypts to ignore the `__select` syntax.
|
||||
|
||||
CI will fail on select, because CI fails on any FZF prompt.
|
||||
|
||||
|
||||
## Logs
|
||||
Quickly view or clear Scwrypts logs.
|
||||
|
||||
|
2
zsh/scwrypts/configure
vendored
2
zsh/scwrypts/configure
vendored
@ -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!'
|
||||
}
|
||||
|
||||
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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 //')
|
||||
|
@ -17,16 +17,19 @@ _SYNCHRONIZE() {
|
||||
|
||||
[ ! $SLIENT ] && {
|
||||
__yN 'change the template before sync?' && __EDIT $__ENV_TEMPLATE
|
||||
_SORT_ENV "$__ENV_TEMPLATE"
|
||||
git add $__ENV_TEMPLATE >/dev/null 2>&1
|
||||
}
|
||||
|
||||
_SORT_ENV "$__ENV_TEMPLATE"
|
||||
sed -i '/__[a-z_]\+=$/d' "$__ENV_TEMPLATE"
|
||||
git add $__ENV_TEMPLATE >/dev/null 2>&1
|
||||
|
||||
ENVIRONMENTS=$(__GET_ENV_NAMES | sort -r)
|
||||
|
||||
_CLEAR_INHERITED_VARIABLES
|
||||
_INSERT_NEW_VARIABLES
|
||||
_REMOVE_OLD_VARIABLES
|
||||
_SORT_AND_CASCADE
|
||||
_ADD_DESCRIPTIONS
|
||||
|
||||
__SUCCESS 'finished sync!'
|
||||
}
|
||||
@ -67,6 +70,8 @@ _REMOVE_OLD_VARIABLES() {
|
||||
while read line
|
||||
do
|
||||
ENV_VAR=$(echo "$line" | sed 's/=.*/=/')
|
||||
echo $ENV_VAR | grep -q '__[a-z_]\+=' && continue
|
||||
|
||||
grep -q "$ENV_VAR" "$__ENV_TEMPLATE" || {
|
||||
sed -i "\\%$ENV_VAR%d" "$ENV_FILE"
|
||||
echo "$ENV_VAR" | grep -qv '^#' \
|
||||
@ -126,5 +131,24 @@ _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")
|
||||
|
||||
for ENV_NAME in $(echo $ENVIRONMENTS)
|
||||
do
|
||||
sed -i "/^# /i \ " "$(__GET_ENV_FILE $ENV_NAME)"
|
||||
sed -i "s/^ $//" "$(__GET_ENV_FILE $ENV_NAME)"
|
||||
done
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
_SYNCHRONIZE $@
|
||||
|
@ -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)]}"
|
||||
}
|
||||
|
@ -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' \
|
||||
|
@ -14,6 +14,12 @@ __CHECK_ENV_VAR() {
|
||||
local VALUE=$(eval echo '$'$NAME)
|
||||
[ $VALUE ] && return 0
|
||||
|
||||
local SELECTION_VALUES=$(eval echo '$'$NAME'__select' | sed 's/,/\n/g')
|
||||
[ $SELECTION_VALUES ] && {
|
||||
local SELECTION=$(echo $SELECTION_VALUES | __FZF "select a value for '$NAME'")
|
||||
[ $SELECTION ] && export VALUE=$SELECTION
|
||||
}
|
||||
[ $VALUE ] && return 0
|
||||
|
||||
[ $__SCWRYPT ] && {
|
||||
# scwrypts exclusive (missing vars staged in env.template)
|
||||
|
@ -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,28 @@ __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
|
||||
@ -63,23 +85,29 @@ __FZF() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
fzf -i --height=30% --layout=reverse --prompt "$1 : " ${@:2}
|
||||
local SELECTION=$(fzf -i --height=30% --layout=reverse --prompt "$1 : " ${@:2})
|
||||
__PROMPT "$1"
|
||||
echo $SELECTION >&2
|
||||
echo $SELECTION
|
||||
}
|
||||
__FZF_HEAD() { __FZF $@ --print-query | sed '/^$/d' | head -n1; } # prefer user input over selected
|
||||
__FZF_TAIL() { __FZF $@ --print-query | sed '/^$/d' | tail -n1; } # prefer selected over user input
|
||||
|
||||
__READ() {
|
||||
[ $CI ] && {
|
||||
__ERROR 'currently in CI, but __READ explicitly requires terminal input'
|
||||
return 1
|
||||
__INFO 'currently in CI, skipping __READ'
|
||||
return 0
|
||||
}
|
||||
read $@ </dev/tty
|
||||
}
|
||||
|
||||
__EDIT() {
|
||||
[ $CI ] && {
|
||||
__ERROR 'currently in CI, but __EDIT explicitly requires terminal input'
|
||||
return 1
|
||||
__INFO 'currently in CI, skipping __EDIT'
|
||||
return 0
|
||||
}
|
||||
|
||||
__STATUS "opening '$1' for editing"
|
||||
$EDITOR $@ </dev/tty >/dev/tty
|
||||
__SUCCESS "finished editing '$1'!"
|
||||
}
|
||||
|
@ -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
8
zsh/vim/common.zsh
Normal 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
49
zsh/vim/vundle/common.zsh
Normal file
@ -0,0 +1,49 @@
|
||||
_DEPENDENCIES+=()
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/../common.zsh
|
||||
#####################################################################
|
||||
|
||||
VUNDLE_PLUGIN_DIR="$HOME/.vim/bundle"
|
||||
VUNDLE_BUILD_DEFINITIONS="$SCWRYPTS_CONFIG_PATH/vundle.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
|
||||
}
|
6
zsh/vim/vundle/edit-build-actions
Executable file
6
zsh/vim/vundle/edit-build-actions
Executable 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
13
zsh/vim/vundle/install
Executable 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
6
zsh/vim/vundle/rebuild
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/zsh
|
||||
_DEPENDENCIES+=()
|
||||
_REQUIRED_ENV+=()
|
||||
source ${0:a:h}/common.zsh
|
||||
#####################################################################
|
||||
VUNDLE_REBUILD_PLUGINS $@
|
Reference in New Issue
Block a user