🦈🏠🐜 Initial Commit 🐜🦈🏠

This commit is contained in:
Jason
2022-07-06 07:07:00 -04:00
commit 4ec9719a1c
13 changed files with 795 additions and 0 deletions

83
bin/entrypoint-vim.sh Executable file
View File

@@ -0,0 +1,83 @@
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202202021753-git
# @Author : Jason Hempstead
# @Contact : jason@casjaysdev.com
# @License : WTFPL
# @ReadME : entrypoint-vim.sh --help
# @Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @Created : Wednesday, Feb 02, 2022 17:53 EST
# @File : entrypoint-vim.sh
# @Description :
# @TODO :
# @Other :
# @Resource :
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPNAME="$(basename "$0")"
VERSION="202202021753-git"
USER="${SUDO_USER:-${USER}}"
HOME="${USER_HOME:-${HOME}}"
SRC_DIR="${BASH_SOURCE%/*}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
if [[ "$1" == "--debug" ]]; then shift 1 && set -xo pipefail && export SCRIPT_OPTS="--debug" && export _DEBUG="on"; fi
trap 'exitCode=${exitCode:-$?};[ -n "$ENTRYPOINT_SH_TEMP_FILE" ] && [ -f "$ENTRYPOINT_SH_TEMP_FILE" ] && rm -Rf "$ENTRYPOINT_SH_TEMP_FILE" &>/dev/null' EXIT
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__exec_bash() { [ -n "$1" ] && exec /bin/bash -l -c "${@:-bash}" || exec /bin/bash -l; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CONFIG_DIR="$(ls -A /config/ 2>/dev/null | grep '^' || false)"
SHELL="${SHELL:-/bin/bash}"
VIMRC="${VIMRC:-$HOME/.vimrc}"
VIM_INDENT="${VIM_INDENT:-2}"
TERM="${TERM:-xterm-256color}"
HOSTNAME="${HOSTNAME:-casjaysdev-vim}"
TZ="${TZ:-America/New_York}"
export TZ HOSTNAME
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ -n "${TZ}" ] && echo "${TZ}" >/etc/timezone
[ -n "${HOSTNAME}" ] && echo "${HOSTNAME}" >/etc/hostname
[ -n "${HOSTNAME}" ] && echo "127.0.0.1 $HOSTNAME localhost" >/etc/hosts
[ -f "/usr/share/zoneinfo/${TZ}" ] && ln -sf "/usr/share/zoneinfo/${TZ}" "/etc/localtime"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -n "$CONFIG_DIR" ]; then
for config in $CONFIG_DIR; do
if [ -d "/config/$config" ]; then
cp -Rf "/config/$config/." "/root/$config/"
elif [ -f "/config/$config" ]; then
cp -Rf "/config/$config" "/root/$config"
fi
done
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[[ -f "/config/vimrc" ]] || { [[ -f "/root/.vimrc" ]] && cp -Rf "/root/.vimrc" "/config/vimrc"; }
[[ -f "/config/tmux.conf" ]] || { [[ -f "/root/.tmux.conf" ]] && cp -Rf "/root/.tmux.conf" "/config/tmux.conf"; }
[[ -d "/config/resurrect" ]] || { [[ -d "/root/.cache/resurrect" ]] && mkdir -p "/config/resurrect" && cp -Rf "/root/.cache/resurrect/." "/config/resurrect/"; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [[ -f "$VIMRC" ]]; then
sed -i 's|set ts=4|set ts='$VIM_INDENT'|g' "$VIMRC"
sed -i 's|set shiftwidth=4|set shiftwidth='$VIM_INDENT'|g' "$VIMRC"
else
echo "Could not find .vimrc at $VIMRC"
exit 1
fi
case "$1" in
healthcheck)
if [[ -f "$VIMRC" ]] && builtin type -P vim &>/dev/null; then
exit 0
else
exit 1
fi
;;
bash | shell | sh)
shift 1
__exec_bash "$@"
;;
tmux)
shift 1
exec tmux "$@"
;;
*)
__exec_bash "$@"
;;
esac

12
bin/renew_env.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eu
pane_fmt="#{pane_id} #{pane_in_mode} #{pane_input_off} #{pane_dead} #{pane_current_command}"
tmux list-panes -s -F "$pane_fmt" | awk '
$2 == 0 && $3 == 0 && $4 == 0 && $5 ~ /(bash|zsh|ksh|fish)/ { print $1 }
' | while read -r pane_id; do
# renew environment variables according to update-environment tmux option
# also clear screen
tmux send-keys -t "$pane_id" 'Enter' 'eval "$(tmux show-env -s)"' 'Enter' 'C-l'
done

42
bin/tmux-plugins Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPNAME="$(basename "$0")"
VERSION="202108242343-git"
USER="${SUDO_USER:-${USER}}"
HOME="${USER_HOME:-${HOME}}"
SRC_DIR="${BASH_SOURCE%/*}"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
[[ "$1" == "--debug" ]] && shift 1 && set -euo pipefail
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202108242343-git
# @Author : Jason Hempstead
# @Contact : jason@casjaysdev.com
# @License : WTFPL
# @ReadME : install_plugins.sh
# @Copyright : Copyright: (c) 2021 Jason Hempstead, CasjaysDev
# @Created : Tuesday, Aug 24, 2021 23:43 EDT
# @File : install_plugins.sh
# @Description : Install tmux plugins
# @TODO :
# @Other :
# @Resource :
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TMUX_HOME="$HOME/.config/tmux"
TMUX_SHARE_DIR="$HOME/.local/share/tmux"
TMUX_PLUGIN_MANAGER_PATH="$TMUX_SHARE_DIR/tpm"
export TMUX_HOME TMUX_PLUGIN_MANAGER_PATH TMUX_SHARE_DIR
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[[ -d "$TMUX_PLUGIN_MANAGER_PATH/.git" ]] && git -C "$TMUX_PLUGIN_MANAGER_PATH" pull ||
git clone https://github.com/tmux-plugins/tpm "$TMUX_PLUGIN_MANAGER_PATH"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ -x "$TMUX_PLUGIN_MANAGER_PATH/bin/install_plugins" ] &&
$TMUX_PLUGIN_MANAGER_PATH/bin/install_plugins
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mkdir -p "$TMUX_SHARE_DIR/resurrect"
[[ -f "$TMUX_HOME/resurrect" ]] && ln -sf "$TMUX_HOME/resurrect" "$TMUX_SHARE_DIR/resurrect/last"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#[[ -f "$TMUX_PLUGIN_MANAGER_PATH/tpm" ]] && [[ -f "$TMUX_SHARE_DIR/resurrect/last" ]] && echo "Install completed"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
exit ${exitCode:-0}

85
bin/weather Executable file
View File

@@ -0,0 +1,85 @@
#!/usr/bin/env sh
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202207060010-git
# @Author : Jason Hempstead
# @Contact : jason@casjaysdev.com
# @License : LICENSE.md
# @ReadME : weather --help
# @Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @Created : Wednesday, Jul 06, 2022 00:10 EDT
# @File : weather
# @Description : get weather - used by tmux
# @TODO :
# @Other :
# @Resource :
# @sudo/root : no
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PROG="$(basename "$0" 2>/dev/null)"
USER="${SUDO_USER:-${USER}}"
HOME="${USER_HOME:-${HOME}}"
SRC_DIR="$(dirname "$PROG")"
VERSION="202207060012-git"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
if [ "$1" = "--debug" ]; then shift 1 && set -xo && export SCRIPT_OPTS="--debug" && export _DEBUG="on"; fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Check for needed applications
#type -P sh &>/dev/null || exit 1 # exit if not found
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set variables
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set functions
__version() { echo "$VERSION"; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set additional variables
exitCode=""
GEN_SCRIPT_ARRAY_DIR="$HOME/.config/weather"
WEATHER_CONFIG_DIR="$HOME/.config/weather"
WEATHER_CONFIG_FILE="settings.conf"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# bring in user config
[ -f "$WEATHER_CONFIG_DIR/$WEATHER_CONFIG_FILE" ] && . "$WEATHER_CONFIG_DIR/$WEATHER_CONFIG_FILE"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Argument/Option settings
SETARGS="$*"
SHORTOPTS="v,h"
LONGOPTS="options,config,version,help"
ARRAY=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Setup application options
setopts=$(getopt -o "$SHORTOPTS" --long "$LONGOPTS" -n "$APPNAME" -- "$@" 2>/dev/null)
eval set -- "${setopts}" 2>/dev/null
while :; do
case $1 in
--version)
shift 1
__version
;;
--help)
shift 1
printf 'Display current weather in your terminal'
;;
--config)
shift 1
__gen_config
;;
--)
shift 1
break
;;
esac
done
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Main application
curl -q -LSsf "http://wttr.in/?format=3" | awk '{print $1,$(NF-1),$NF}' | sed 's|, |: |g' || echo N/A
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# End application
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# lets exit with code
exit ${exitCode:-$?}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# end

67
bin/yank.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -eu
cmd_exists() {
type "$1" &>/dev/null || return 1
}
# get data either form stdin or from file
buf=$(cat "$@")
copy_backend_remote_tunnel_port=$(tmux show-option -gvq "@copy_backend_remote_tunnel_port")
copy_use_osc52_fallback=$(tmux show-option -gvq "@copy_use_osc52_fallback")
# Resolve copy backend: pbcopy (OSX), reattach-to-user-namespace (OSX), xclip/xsel (Linux)
copy_backend=""
if cmd_exists pbcopy; then
copy_backend="pbcopy"
elif cmd_exists reattach-to-user-namespace; then
copy_backend="reattach-to-user-namespace pbcopy"
elif [ -n "${DISPLAY-}" ] && cmd_exists xsel; then
copy_backend="xsel -i --clipboard"
elif [ -n "${DISPLAY-}" ] && cmd_exists xclip; then
copy_backend="xclip -i -f -selection primary | xclip -i -selection clipboard"
elif [ -n "${copy_backend_remote_tunnel_port-}" ] &&
(netstat -f inet -nl 2>/dev/null || netstat -4 -nl 2>/dev/null) |
grep -q "[.:]$copy_backend_remote_tunnel_port"; then
copy_backend="nc localhost $copy_backend_remote_tunnel_port"
fi
# if copy backend is resolved, copy and exit
if [ -n "$copy_backend" ]; then
printf "%s" "$buf" | eval "$copy_backend"
exit
fi
# If no copy backends were eligible, decide to fallback to OSC 52 escape sequences
# Note, most terminals do not handle OSC
if [ "$copy_use_osc52_fallback" == "off" ]; then
exit
fi
# Copy via OSC 52 ANSI escape sequence to controlling terminal
buflen=$(printf %s "$buf" | wc -c)
# https://sunaku.github.io/tmux-yank-osc52.html
# The maximum length of an OSC 52 escape sequence is 100_000 bytes, of which
# 7 bytes are occupied by a "\033]52;c;" header, 1 byte by a "\a" footer, and
# 99_992 bytes by the base64-encoded result of 74_994 bytes of copyable text
maxlen=74994
# warn if exceeds maxlen
if [ "$buflen" -gt "$maxlen" ]; then
printf "input is %d bytes too long" "$((buflen - maxlen))" >&2
fi
# build up OSC 52 ANSI escape sequence
esc="\033]52;c;$(printf %s "$buf" | head -c $maxlen | base64 | tr -d '\r\n')\a"
esc="\033Ptmux;\033$esc\033\\"
# resolve target terminal to send escape sequence
# if we are on remote machine, send directly to SSH_TTY to transport escape sequence
# to terminal on local machine, so data lands in clipboard on our local machine
pane_active_tty=$(tmux list-panes -F "#{pane_active} #{pane_tty}" | awk '$1=="1" { print $2 }')
target_tty="${SSH_TTY:-$pane_active_tty}"
printf '%s' "$esc" >"$target_tty"