style(profile): sweep with shell harden
This commit is contained in:
parent
3063add75c
commit
a44c348470
140
.profile
140
.profile
@ -6,20 +6,20 @@ ulimit -n 10000 # Allows for more open files
|
||||
# shellcheck source=./.zstyle
|
||||
source ~/.zstyle
|
||||
|
||||
. "${HOME}/.cargo/env"
|
||||
. "$HOME/.cargo/env"
|
||||
|
||||
### Pathing ###
|
||||
|
||||
export PATH="${HOME}/.bin:${PATH}"
|
||||
export PATH="${PATH}:/opt/homebrew/Cellar/llvm/13.0.0_2/bin"
|
||||
export PATH="$HOME/.bin:$PATH"
|
||||
export PATH="$PATH:/opt/homebrew/Cellar/llvm/13.0.0_2/bin"
|
||||
|
||||
# Mac pathing beneath
|
||||
if [[ "${OSTYPE}" = "darwin"* ]]; then
|
||||
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:${PATH}"
|
||||
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:${PATH}"
|
||||
export PATH="/Applications/Firefox Developer Edition.app/Contents/MacOS:${PATH}"
|
||||
export PATH="${HOME}/.rustup/toolchains/stable-aarch64-apple-darwin/bin:${PATH}"
|
||||
export MANPATH="/opt/homebrew/opt/coreutils/libexec/gnuman:${MANPATH}"
|
||||
if [[ "$OSTYPE" = "darwin"* ]]; then
|
||||
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
|
||||
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
|
||||
export PATH="/Applications/Firefox Developer Edition.app/Contents/MacOS:$PATH"
|
||||
export PATH="$HOME/.rustup/toolchains/stable-aarch64-apple-darwin/bin:$PATH"
|
||||
export MANPATH="/opt/homebrew/opt/coreutils/libexec/gnuman:$MANPATH"
|
||||
|
||||
complete -o nospace -C /opt/homebrew/bin/terraform terraform
|
||||
|
||||
@ -28,7 +28,7 @@ if [[ "${OSTYPE}" = "darwin"* ]]; then
|
||||
eval "$(pyenv init -)"
|
||||
|
||||
# LLDB
|
||||
export PATH="/opt/homebrew/opt/llvm/bin:${PATH}"
|
||||
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
|
||||
fi
|
||||
|
||||
### OPTS ###
|
||||
@ -44,7 +44,7 @@ export AWS_CLI_AUTO_PROMPT=on
|
||||
export ZSH_HIGHLIGHT_MAXLENGTH=10000
|
||||
export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=2
|
||||
export LANG=en_US.UTF-8
|
||||
export NOTES_DIR="${HOME}/.notes"
|
||||
export NOTES_DIR="$HOME/.notes"
|
||||
export DOCKER_BUILDKIT=1
|
||||
|
||||
# Fzf Variables
|
||||
@ -66,7 +66,7 @@ fi
|
||||
# If using the kitty terminal we want to set our TERM var to be xterm as kitty will send
|
||||
# kitty-xterm which causes a fucking headache and a half due to ncurses not containing
|
||||
# that by default
|
||||
if [[ "${TERM}" = *"xterm-kitty"* ]]; then
|
||||
if [[ "$TERM" = *"xterm-kitty"* ]]; then
|
||||
alias ssh="TERM=xterm-256color ssh"
|
||||
alias icat="kitty +kitten icat"
|
||||
__kitty_complete
|
||||
@ -77,7 +77,7 @@ fi
|
||||
# Makes the cursor change based on the mode
|
||||
export VI_MODE_SET_CURSOR=true
|
||||
# Set the editor to neovim for visual mode
|
||||
export ZVM_VI_EDITOR="${EDITOR}"
|
||||
export ZVM_VI_EDITOR="$EDITOR"
|
||||
# This ensures that fzf completion works
|
||||
zvm_after_init_commands+=('[[ -r ~/.fzf.zsh ]] && source ~/.fzf.zsh')
|
||||
|
||||
@ -118,11 +118,11 @@ gbf() {
|
||||
local remote
|
||||
local default_branch
|
||||
remote="${1:=origin}"
|
||||
default_branch="$(git remote show "${remote}" | awk '/HEAD branch/ {print $NF}')"
|
||||
git fetch "${remote}" "${default_branch}":"${default_branch}"
|
||||
default_branch="$(git remote show "$remote" | awk '/HEAD branch/ {print $NF}')"
|
||||
git fetch "$remote" "$default_branch":"$default_branch"
|
||||
}
|
||||
## Mac Specific Aliases ##
|
||||
if [[ "${OSTYPE}" = "darwin"* ]]; then
|
||||
if [[ "$OSTYPE" = "darwin"* ]]; then
|
||||
alias c="pbcopy"
|
||||
alias p="pbpaste"
|
||||
alias grep="ggrep"
|
||||
@ -142,27 +142,27 @@ if which bat >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
## Misc Aliases ##
|
||||
alias e="${EDITOR}"
|
||||
alias e="$EDITOR"
|
||||
alias ghidra="ghidraRun"
|
||||
alias v="vim"
|
||||
alias :q="exit"
|
||||
alias Get-Public-IPV4="dig @resolver4.opendns.com myip.opendns.com +short -4"
|
||||
alias Get-Public-IPV6="dig @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6"
|
||||
alias :profile="${EDITOR} ${HOME}/.profile"
|
||||
alias :profile="$EDITOR $HOME/.profile"
|
||||
|
||||
### Completions ###
|
||||
|
||||
# Homebrew completions
|
||||
if type brew &>/dev/null; then
|
||||
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
|
||||
FPATH="$(brew --prefix)/share/zsh/site-functions:$FPATH"
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
fi
|
||||
|
||||
# Completions from .zsh directory
|
||||
if [[ -d "${HOME}/.zsh/completions" ]]; then
|
||||
FPATH="${HOME}/.zsh/completions:${FPATH}"
|
||||
if [[ -d "$HOME/.zsh/completions" ]]; then
|
||||
FPATH="$HOME/.zsh/completions:$FPATH"
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
@ -171,15 +171,15 @@ fi
|
||||
### Functions ###
|
||||
del() {
|
||||
local BASE_TRASH_DIR
|
||||
BASE_TRASH_DIR="${HOME}/.Trash/"
|
||||
BASE_TRASH_DIR="$HOME/.Trash/"
|
||||
|
||||
local trash_del_dir
|
||||
trash_del_dir="${BASE_TRASH_DIR}/del-$(date +%Y-%m-%dT%H:%M:%S)"
|
||||
trash_del_dir="$BASE_TRASH_DIR/del-$(date +%Y-%m-%dT%H:%M:%S)"
|
||||
|
||||
mkdir -p "${trash_del_dir}"
|
||||
mkdir -p "$trash_del_dir"
|
||||
|
||||
for i in "${@}"; do
|
||||
mv "${i}" "${trash_del_dir}"
|
||||
mv "$i" "$trash_del_dir"
|
||||
done
|
||||
}
|
||||
|
||||
@ -209,18 +209,18 @@ TCPDump-Capture() {
|
||||
|
||||
Known-Hosts() {
|
||||
local prev_ifs
|
||||
prev_ifs="${IFS}"
|
||||
prev_ifs="$IFS"
|
||||
while IFS=$'\n' read -r line; do
|
||||
echo "${line}" | cut -d " " -f1
|
||||
echo "$line" | cut -d " " -f1
|
||||
done <~/.ssh/known_hosts
|
||||
IFS="${prev_ifs}"
|
||||
IFS="$prev_ifs"
|
||||
}
|
||||
|
||||
Work-Hours() {
|
||||
local WORK_HOURS_PATH
|
||||
WORK_HOURS_PATH=~/Vircio/Work-Hours
|
||||
mkdir -p "${WORK_HOURS_PATH}"
|
||||
${EDITOR} "${WORK_HOURS_PATH}/$(date +%Y-%m-%d)"
|
||||
mkdir -p "$WORK_HOURS_PATH"
|
||||
"$EDITOR" "$WORK_HOURS_PATH/$(date +%Y-%m-%d)"
|
||||
}
|
||||
|
||||
date_iso_8601() {
|
||||
@ -276,28 +276,28 @@ echo_rgb() {
|
||||
bg_blue="${7}"
|
||||
|
||||
for num in "${@:2}"; do
|
||||
[[ ! "${num}" =~ [0-9] ]] &&
|
||||
printf "%s\n" "Given RGB value was not a number, received ${num}" 1>&2 &&
|
||||
[[ ! "$num" =~ [0-9] ]] &&
|
||||
printf "%s\n" "Given RGB value was not a number, received $num" 1>&2 &&
|
||||
return 1
|
||||
[[ "${num}" -gt 255 ]] &&
|
||||
printf "%s\n" "Given RGB value must be less than 255, received ${num}" 1>&2 &&
|
||||
[[ "$num" -gt 255 ]] &&
|
||||
printf "%s\n" "Given RGB value must be less than 255, received $num" 1>&2 &&
|
||||
return 1
|
||||
[[ "${num}" -lt 0 ]] &&
|
||||
printf "%s\n" "Given RGB value must be more than 0, received ${num}" 1>&2 &&
|
||||
[[ "$num" -lt 0 ]] &&
|
||||
printf "%s\n" "Given RGB value must be more than 0, received $num" 1>&2 &&
|
||||
return 1
|
||||
done
|
||||
|
||||
if [ -t 1 ]; then
|
||||
if [ -n "${5}" ]; then
|
||||
if [ "${5}" != "" ]; then
|
||||
[[ -z "${6}" ]] && echo "A value must be passed for bg_green" && return 1
|
||||
[[ -z "${7}" ]] && echo "A value must be passed for bg_blue" && return 1
|
||||
printf "\033[38;2;%s;%s;%s;48;2;%s;%s;%sm%s\033[m\n" \
|
||||
"${red}" "${green}" "${blue}" "${bg_red}" "${bg_green}" "${bg_blue}" "${input}"
|
||||
"$red" "$green" "$blue" "$bg_red" "$bg_green" "$bg_blue" "$input"
|
||||
else
|
||||
printf "\033[0;38;2;%s;%s;%sm%s\033[m\n" "${red}" "${green}" "${blue}" "${input}"
|
||||
printf "\033[0;38;2;%s;%s;%sm%s\033[m\n" "$red" "$green" "$blue" "$input"
|
||||
fi
|
||||
else
|
||||
printf "%s\n" "${input}"
|
||||
printf "%s\n" "$input"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -316,12 +316,12 @@ tmp() {
|
||||
tmp=$(mktemp -d)
|
||||
export tmp
|
||||
trap 'rm -rf ${tmp}' 0
|
||||
if ! cd "${tmp}"; then
|
||||
printf "%s \"%s\"\n" "Unable to cd into" "${tmp}"
|
||||
if ! cd "$tmp"; then
|
||||
printf "%s \"%s\"\n" "Unable to cd into" "$tmp"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$1" ]; then
|
||||
$SHELL -l
|
||||
if [ "$1" = "" ]; then
|
||||
"$SHELL" -l
|
||||
else
|
||||
[ "$1" = "-l" ] && {
|
||||
shift
|
||||
@ -348,14 +348,14 @@ nvim_env() {
|
||||
local nvim_env_full_path
|
||||
|
||||
nvim_env="${1:-nvim-primary}"
|
||||
nvim_env_path="${HOME}/nvim-environments"
|
||||
nvim_env_full_path="${nvim_env_path}/${nvim_env}"
|
||||
nvim_env_path="$HOME/nvim-environments"
|
||||
nvim_env_full_path="$nvim_env_path/$nvim_env"
|
||||
|
||||
declare -A nvim_syml_paths=(["${HOME}/.config/nvim"]="${nvim_env_full_path}/config" ["${HOME}/.local/share/nvim"]="${nvim_env_full_path}/share")
|
||||
declare -A nvim_syml_paths=(["$HOME/.config/nvim"]="$nvim_env_full_path/config" ["$HOME/.local/share/nvim"]="$nvim_env_full_path/share")
|
||||
|
||||
# Check that the given environment exists
|
||||
if [[ ! -d "${nvim_env_full_path}" ]]; then
|
||||
printf "Error: Unable to locate environment, \"%s\"\n\t\"%s\"\n" "${nvim_env}" "${nvim_env_full_path}" >&2
|
||||
if [[ ! -d "$nvim_env_full_path" ]]; then
|
||||
printf "Error: Unable to locate environment, \"%s\"\n\t\"%s\"\n" "$nvim_env" "$nvim_env_full_path" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -363,42 +363,42 @@ nvim_env() {
|
||||
local symlink_dst
|
||||
for syml_key in "${!nvim_syml_paths[@]}"; do
|
||||
symlink_src="${nvim_syml_paths[$syml_key]}"
|
||||
symlink_dst="${syml_key}"
|
||||
symlink_dst="$syml_key"
|
||||
|
||||
# Check that the configuration path exist from our env
|
||||
if [[ ! -d "${symlink_src}" ]]; then
|
||||
printf "ERROR: Unable to find configuration:\n\t\"%s\" in environment \"%s\"\n\tConsider creating it with \"mkdir -p %s\"\n" "${symlink_src}" "${nvim_env}" "${symlink_src}" >&2
|
||||
if [[ ! -d "$symlink_src" ]]; then
|
||||
printf "ERROR: Unable to find configuration:\n\t\"%s\" in environment \"%s\"\n\tConsider creating it with \"mkdir -p %s\"\n" "$symlink_src" "$nvim_env" "$symlink_src" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If a directory (not a symlink) exists in where we want to write a symlink refuse to overwrite
|
||||
if [[ -r "${symlink_dst}" ]] && [[ ! -L "${symlink_dst}" ]]; then
|
||||
printf "ERROR: Neovim configuration to be replaced is not a symlink, please remove the files before proceeding, issue file:\n\t\"%s\"\n" "${symlink_dst}" >&2
|
||||
if [[ -r "$symlink_dst" ]] && [[ ! -L "$symlink_dst" ]]; then
|
||||
printf "ERROR: Neovim configuration to be replaced is not a symlink, please remove the files before proceeding, issue file:\n\t\"%s\"\n" "$symlink_dst" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If we find an existing symlink, try to delete it
|
||||
if [[ -L "${symlink_dst}" ]]; then
|
||||
if [[ -L "$symlink_dst" ]]; then
|
||||
local linked_sym
|
||||
linked_sym="$(readlink "${symlink_dst}")"
|
||||
printf "Attemping to remove symlink:\n\t%s -> %s\n" "${linked_sym}" "${symlink_dst}"
|
||||
if ! rm "${symlink_dst}"; then
|
||||
printf "ERROR: Failed to remove symlink:\n\t%s -> %s\n" "${linked_sym}" "${symlink_dst}" >&2
|
||||
linked_sym="$(readlink "$symlink_dst")"
|
||||
printf "Attemping to remove symlink:\n\t%s -> %s\n" "$linked_sym" "$symlink_dst"
|
||||
if ! rm "$symlink_dst"; then
|
||||
printf "ERROR: Failed to remove symlink:\n\t%s -> %s\n" "$linked_sym" "$symlink_dst" >&2
|
||||
return 1
|
||||
else
|
||||
printf "Successfully removed symlink:\n\t%s -> %s\n" "${linked_sym}" "${symlink_dst}"
|
||||
printf "Successfully removed symlink:\n\t%s -> %s\n" "$linked_sym" "$symlink_dst"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Actually write the env now we're past our guards
|
||||
printf "Linking:\n\t%s -> %s\n" "${symlink_src}" "${symlink_dst}"
|
||||
if ! ln -s "${symlink_src}" "${symlink_dst}"; then
|
||||
printf "ERROR: Failed to link:\n\t%s -> %s\n" "${symlink_src}" "${symlink_dst}" >&2
|
||||
printf "Linking:\n\t%s -> %s\n" "$symlink_src" "$symlink_dst"
|
||||
if ! ln -s "$symlink_src" "$symlink_dst"; then
|
||||
printf "ERROR: Failed to link:\n\t%s -> %s\n" "$symlink_src" "$symlink_dst" >&2
|
||||
return 1
|
||||
else
|
||||
printf "Successfully linked:\n\t%s -> %s\n" "${symlink_src}" "${symlink_dst}"
|
||||
printf "Successfully linked:\n\t%s -> %s\n" "$symlink_src" "$symlink_dst"
|
||||
fi
|
||||
printf "%.s-" $(seq 1 $(tput cols))
|
||||
printf "%.s-" "$(seq 1 "$(tput cols)")"
|
||||
printf "\n"
|
||||
done
|
||||
}
|
||||
@ -409,7 +409,7 @@ browser_search() {
|
||||
local search_term
|
||||
browser="firefox"
|
||||
search_term="${*}"
|
||||
eval "${browser} -search \"${search_term}\""
|
||||
eval "$browser -search \"$search_term\""
|
||||
}
|
||||
|
||||
### Search Aliases ###
|
||||
@ -429,21 +429,21 @@ watcher() {
|
||||
sleep_time="${2:-5}"
|
||||
while :; do
|
||||
clear
|
||||
printf "%s | %s | %s\n" "Command: \"${command}\"" "Every ${sleep_time} seconds" "$(date)"
|
||||
printf "%s | %s | %s\n" "Command: \"$command\"" "Every $sleep_time seconds" "$(date)"
|
||||
printf "%*s\n" "${COLUMNS:-$(tput cols)}" "" | tr " " -
|
||||
eval "${command}"
|
||||
eval "$command"
|
||||
exit_code="${?}"
|
||||
if ((exit_code != 0)); then
|
||||
break
|
||||
fi
|
||||
sleep "${sleep_time}"
|
||||
sleep "$sleep_time"
|
||||
done
|
||||
|
||||
return "$((exit_code))"
|
||||
}
|
||||
|
||||
update_cargo_crates() {
|
||||
cargo install $(cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d" ")
|
||||
cargo install "$(cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d" ")"
|
||||
}
|
||||
|
||||
### FZF FUNCTIONS ###
|
||||
|
Loading…
Reference in New Issue
Block a user