Added zshrc and scripts
This commit is contained in:
parent
3eabb6d77b
commit
1146eee530
35
.config/scripts/aws-profile.sh
Executable file
35
.config/scripts/aws-profile.sh
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function awsconfig {
|
||||||
|
AWS_PROFILE=$(cat ~/.aws/credentials \
|
||||||
|
| grep "\[" \
|
||||||
|
| fzf \
|
||||||
|
| tr -d "[" \
|
||||||
|
| tr -d "]" \
|
||||||
|
| xargs
|
||||||
|
)
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
vim /tmp/raw_keys.tmp
|
||||||
|
|
||||||
|
cat /tmp/raw_keys.tmp | grep -v "\[.*\]$" > /tmp/keys.tmp
|
||||||
|
|
||||||
|
export $(xargs < /tmp/keys.tmp)
|
||||||
|
|
||||||
|
rm /tmp/raw_keys.tmp /tmp/keys.tmp
|
||||||
|
|
||||||
|
aws configure set aws_access_key_id "${aws_access_key_id}" --profile "$AWS_PROFILE"
|
||||||
|
aws configure set aws_secret_access_key "${aws_secret_access_key}" --profile "$AWS_PROFILE"
|
||||||
|
aws configure set aws_session_token "${aws_session_token}" --profile "$AWS_PROFILE"
|
||||||
|
|
||||||
|
echo "Testing AWS Keys..."
|
||||||
|
IAM_RESULT=$(aws sts get-caller-identity --query "Account" --output text --profile "$AWS_PROFILE")
|
||||||
|
|
||||||
|
if [ "$IAM_RESULT" ]; then
|
||||||
|
echo "Credentials work!"
|
||||||
|
else
|
||||||
|
echo "AWS Keys did not work!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
42
.config/scripts/coles.sh
Executable file
42
.config/scripts/coles.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ROOT_URL='https://www.coles.com.au/product'
|
||||||
|
|
||||||
|
# <Price>|<ProductID>
|
||||||
|
declare -a PRODUCT_IDS=(
|
||||||
|
'$40.00|lavazza-espresso-barista-gran-crema-coffee-beans-1kg-3756513|Coffee Beans'
|
||||||
|
'$5.20|tostitos-restaurant-style-smokin-chipotle-sour-cream-165g-6596322|Tostitos'
|
||||||
|
'$8.00|nudie-pulp-oranges-juice-chilled-2l-7895759|Orange Juice'
|
||||||
|
'$2.50|peckish-original-rice-crackers-90g-9999336|Pekish Crackers'
|
||||||
|
'$3.00|liddells-lactose-free-full-cream-milk-1l-6706012|Lactose Free Milk'
|
||||||
|
'$9.50|connoisseur-ice-cream-roasted-hazelnut-4-pack-400ml-5019356|Connoisseur Ice Cream'
|
||||||
|
'$6.90|carman'\''s-dark-choc-espresso-nut-bar-5-pack-160g-1905237|Carmans Espresso Nut Bar'
|
||||||
|
'$9.00|twisted-licks-rich-chocolate-zero-added-sugar-sticks-4-pack-320ml-3778083|Licks Ice Cream'
|
||||||
|
)
|
||||||
|
|
||||||
|
/Users/noahheague/.config/scripts/webhook.sh \
|
||||||
|
-c "coles" \
|
||||||
|
-m "Checking Prices..."
|
||||||
|
|
||||||
|
for PRODUCT in "${PRODUCT_IDS[@]}"
|
||||||
|
do
|
||||||
|
EXPECTED_PRICE=$(echo $PRODUCT | cut -d "|" -f1)
|
||||||
|
PRODUCT_ID=$(echo $PRODUCT | cut -d "|" -f2)
|
||||||
|
PRETTY_NAME=$(echo $PRODUCT | cut -d "|" -f3)
|
||||||
|
|
||||||
|
OUTPUT=$(curl -s "$ROOT_URL\/$PRODUCT_ID" \
|
||||||
|
| /usr/local/bin/ggrep -oP "aria-label=\"Price .*?\"" \
|
||||||
|
| cut -d \" -f2 \
|
||||||
|
| cut -d " " -f2)
|
||||||
|
|
||||||
|
if [[ "$OUTPUT" != "$EXPECTED_PRICE" ]]
|
||||||
|
then
|
||||||
|
/Users/noahheague/.config/scripts/webhook.sh \
|
||||||
|
-c "coles" \
|
||||||
|
-m "$PRETTY_NAME is on sale! **$OUTPUT** (was $EXPECTED_PRICE)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
/Users/noahheague/.config/scripts/webhook.sh \
|
||||||
|
-c "coles" \
|
||||||
|
-m "All prices checked!"
|
60
.config/scripts/compress.sh
Executable file
60
.config/scripts/compress.sh
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
decimate() {
|
||||||
|
ffmpeg -i "$1" -map 0:v -vf mpdecimate,setpts=N/FRAME_RATE/TB "${1%.*}"-decimated.mp4
|
||||||
|
}
|
||||||
|
|
||||||
|
togif() {
|
||||||
|
ffmpeg -i "$1" \
|
||||||
|
-filter_complex "[0:v] fps=12,scale=480:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" \
|
||||||
|
out.gif
|
||||||
|
}
|
||||||
|
|
||||||
|
drive-by() {
|
||||||
|
for file in *.png; do
|
||||||
|
if convert "$file" -channel a -separate -format "%[fx:100*mean]%" info: | grep -qE "(99\.|100)"; then
|
||||||
|
convert "$file" "${file%.png}.jpg"
|
||||||
|
convert "$file" "${file%.png}.webp"
|
||||||
|
echo "Created jpg & webp"
|
||||||
|
else
|
||||||
|
convert "$file" -define png:include-chunk=none -quality 95 -depth 8 "$file"
|
||||||
|
convert "$file" "${file%.png}.webp"
|
||||||
|
echo "Compressed png & created webp"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
site-prep() {
|
||||||
|
mkdir -p lg/;
|
||||||
|
mkdir -p md/;
|
||||||
|
mkdir -p sm/;
|
||||||
|
|
||||||
|
convert "$1" \
|
||||||
|
-strip \
|
||||||
|
-quality 85% \
|
||||||
|
-interlace Plane \
|
||||||
|
-resize 1800 "lg/${1%.*}.jpg"
|
||||||
|
|
||||||
|
convert "$1" \
|
||||||
|
-strip \
|
||||||
|
-interlace Plane \
|
||||||
|
-gaussian-blur 0.05 \
|
||||||
|
-quality 85% \
|
||||||
|
-resize 720 "md/${1%.*}.jpg"
|
||||||
|
|
||||||
|
convert "$1" \
|
||||||
|
-strip \
|
||||||
|
-interlace Plane \
|
||||||
|
-scale 10% \
|
||||||
|
-blur 0x2.5 \
|
||||||
|
-resize 1000% \
|
||||||
|
-resize 180 "sm/${1%.*}.jpg"
|
||||||
|
|
||||||
|
echo "$1 is prepped"
|
||||||
|
}
|
||||||
|
|
||||||
|
flac-ipod() {
|
||||||
|
mkdir ./converted;
|
||||||
|
for file in **/*.flac; do
|
||||||
|
ffmpeg -i "$file" -c:a aac -b:a 256k -aac_pns 0 -movflags +faststart -vn "${file%.flac}.m4a"
|
||||||
|
mv "$file" "./converted";
|
||||||
|
done
|
||||||
|
}
|
11
.config/scripts/dig.sh
Executable file
11
.config/scripts/dig.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
function ezdig() {
|
||||||
|
CNAME="$(dig @1.1.1.1 $1 CNAME | sed -n -e '/ANSWER SECTION/,/;;/ p' | sed -n '/^[a-z]/p')"
|
||||||
|
NS="$(dig @1.1.1.1 $1 NS | sed -n -e '/ANSWER SECTION/,/;;/ p' | sed -n '/^[a-z]/p')"
|
||||||
|
A="$(dig @1.1.1.1 $1 A | sed -n -e '/ANSWER SECTION/,/;;/ p' | sed -n '/^[a-z]/p')"
|
||||||
|
MX="$(dig @1.1.1.1 $1 MX | sed -n -e '/ANSWER SECTION/,/;;/ p' | sed -n '/^[a-z]/p')"
|
||||||
|
|
||||||
|
if [[ -z "${CNAME// }" ]] then; else; echo "$GREEN_TEXT\0CNAME:$DEFAULT_TEXT\n$CNAME\n\n"; fi;
|
||||||
|
if [[ -z "${NS// }" ]] then; else; echo "$GREEN_TEXT\0NS:$DEFAULT_TEXT\n$NS\n\n"; fi;
|
||||||
|
if [[ -z "${A// }" ]] then; else; echo "$GREEN_TEXT\0A:$DEFAULT_TEXT\n$A\n\n"; fi;
|
||||||
|
if [[ -z "${MX// }" ]] then; else; echo "$GREEN_TEXT\0MX:$DEFAULT_TEXT\n$MX"; fi;
|
||||||
|
}
|
21
.config/scripts/encrypt.sh
Normal file
21
.config/scripts/encrypt.sh
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#Encrypt Files
|
||||||
|
function encrypt {
|
||||||
|
FILE_EXTENSION=$(echo $1 | cut -f 2,3 -d '.')
|
||||||
|
FILE_NAME=$(echo "$1" | cut -f 1 -d '.')
|
||||||
|
|
||||||
|
openssl enc -aes-256-cbc -salt -in "$*" -out "$FILE_NAME".enc
|
||||||
|
echo "$GREEN_TEXT\nSend the follow command via Slack alongside the file:$DEFAULT_TEXT\n\`openssl enc -d -aes-256-cbc -in ~/Downloads/$FILE_NAME.enc >> $FILE_NAME.$FILE_EXTENSION"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create a Salted UUID
|
||||||
|
function salted-uuid {
|
||||||
|
# Convert input into base64 string
|
||||||
|
INPUT_AS_BASE64=$(echo -n "$1" | openssl dgst -binary -sha256 | openssl base64)
|
||||||
|
BASE64_SANITIZED=$(echo -n "$INPUT_AS_BASE64" | sed 's/[=\/+-]//g')
|
||||||
|
|
||||||
|
# Add Delimiters to the string
|
||||||
|
BASE_WITH_DELIM=$(echo -n "$BASE64_SANITIZED" | sed -E 's/./&-/32;s/./&-/20;s/./&-/16;s/./&-/12;s/./&-/8')
|
||||||
|
|
||||||
|
# Return with cruft removed
|
||||||
|
echo "$BASE_WITH_DELIM" | cut -f1,2,3,4,5 -d"-"
|
||||||
|
}
|
59
.config/scripts/git_fzf.sh
Normal file
59
.config/scripts/git_fzf.sh
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/zsh
|
||||||
|
|
||||||
|
function is_in_git_repo() {
|
||||||
|
git rev-parse HEAD > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
function fzf-down() {
|
||||||
|
fzf --height 50% "$@" --border
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkout() {
|
||||||
|
is_in_git_repo || return
|
||||||
|
BRANCH=$(git branch -a | sed -e 's/^ *//g' -e '/HEAD ->/d' -e 's/remotes\///g' | fzf --border --query "$1")
|
||||||
|
case "$BRANCH" in
|
||||||
|
*"origin"*) git checkout --track "$BRANCH" ;;
|
||||||
|
*) git checkout "$BRANCH" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
function commit() {
|
||||||
|
is_in_git_repo || return
|
||||||
|
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | cut -f1,2 -d - | cut -f2 -d /)
|
||||||
|
|
||||||
|
if git status | grep -q "serverless.yml"; then
|
||||||
|
echo "$RED_TEXT\nAre you sure you want to commit serverless.yml?"
|
||||||
|
select answer in "Yes" "No"; do
|
||||||
|
case $answer in
|
||||||
|
Yes ) break;;
|
||||||
|
No ) return 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$BRANCH_NAME" != 'master' -a "$BRANCH_NAME" != 'main' -a "$BRANCH_NAME" != 'rnd'; then
|
||||||
|
git commit -m "[$BRANCH_NAME] $*"
|
||||||
|
else
|
||||||
|
echo "$RED_TEXT\nAre you sure you want to commit directly to $BRANCH_NAME?$DEFAULT_TEXT"
|
||||||
|
select answer in "Yes" "No"; do
|
||||||
|
case $answer in
|
||||||
|
Yes ) git commit -m "$*"; break;;
|
||||||
|
No ) return 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
is_in_git_repo || return
|
||||||
|
git add $(git status | grep modified: | sed -e 's/ *.*: *//g' | tac | fzf -m)
|
||||||
|
git status
|
||||||
|
}
|
||||||
|
|
||||||
|
# Restore unstaged files
|
||||||
|
function restore() {
|
||||||
|
is_in_git_repo || return
|
||||||
|
# TODO Adjust this to only list unstaged files!
|
||||||
|
git restore --staged "$(git status | grep modified: | sed -e 's/ *.*: *//g' | tac | fzf -m)"
|
||||||
|
git status
|
||||||
|
}
|
7
.config/scripts/kill.sh
Executable file
7
.config/scripts/kill.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
kill-port() {
|
||||||
|
sudo kill -9 $(lsof -t -i:"$1")
|
||||||
|
}
|
||||||
|
|
||||||
|
kill-all() {
|
||||||
|
sudo kill -9 $(pgrep "$1")
|
||||||
|
}
|
0
.config/scripts/lint.sh
Normal file
0
.config/scripts/lint.sh
Normal file
10
.config/scripts/rg_fzf.sh
Executable file
10
.config/scripts/rg_fzf.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function rgfzf() {
|
||||||
|
FZF_SELECTION=$(rg -g '!*.{svg,js}' . | fzf)
|
||||||
|
FILE_NAME=$(echo "$FZF_SELECTION" | cut -d':' -f1)
|
||||||
|
CONTENT=$(echo "$FZF_SELECTION" | cut -d':' -f2-)
|
||||||
|
ESCAPED=$(echo "$CONTENT" | sed -e 's,/,\\/,g')
|
||||||
|
|
||||||
|
vim "$FILE_NAME" -c "/$ESCAPED"
|
||||||
|
}
|
67
.config/scripts/scratch.sh
Executable file
67
.config/scripts/scratch.sh
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function scratch () {
|
||||||
|
requestedDate=$(date +"%y-%m-%d")
|
||||||
|
vim ~/Documents/Scratchpad/$requestedDate.md
|
||||||
|
}
|
||||||
|
|
||||||
|
function wscratch () {
|
||||||
|
requestedDate=$(date +"%y-%m-%d")
|
||||||
|
if [ ! -e ~/Documents/Scratchpad-write/$requestedDate-write.md ]; then
|
||||||
|
touch ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "---" >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "title: " >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "summary: " >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "image: " >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "alt: " >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "attribution: " >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
echo "---" >> ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
fi
|
||||||
|
vim ~/Documents/Scratchpad-write/$requestedDate-write.md
|
||||||
|
}
|
||||||
|
|
||||||
|
function nscratch () {
|
||||||
|
requestedDate=$(date +"%y-%m-%d")
|
||||||
|
if [ ! -e ~/Documents/Scratchpad-now/$requestedDate-write.md ]; then
|
||||||
|
touch ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
echo "---" >> ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
echo "title: " >> ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
echo "---" >> ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
echo "" >> ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
echo "Today I " >> ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
fi
|
||||||
|
vim ~/Documents/Scratchpad-now/$requestedDate-write.md
|
||||||
|
}
|
||||||
|
|
||||||
|
function codeScratch () {
|
||||||
|
cd ~/Developer/Scratch/ || exit
|
||||||
|
DATE=$(date +"%y-%m-%d")
|
||||||
|
if test ! -d "$(pwd)/$DATE"; then
|
||||||
|
mkdir "$(pwd)/$DATE";
|
||||||
|
cd "$(pwd)/$DATE" || exit
|
||||||
|
|
||||||
|
# Setup project
|
||||||
|
pnpm init
|
||||||
|
pnpm install @types/node ts-node-dev typescript prettier -D
|
||||||
|
if test ! $# -eq 0; then
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
pnpm install $*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Essential files
|
||||||
|
echo '{"compilerOptions": {"module": "commonjs","esModuleInterop": true,"target": "es6","moduleResolution": "node","sourceMap": true,"outDir": "dist"},"lib": ["es2015"]}' > tsconfig.json
|
||||||
|
echo 'module.exports={semi: true,singleQuote: true,tabWidth: 2,trailingComma: "all",arrowParens: "always",printWidth: 80};' > .prettierrc.js
|
||||||
|
echo 'console.log("hello world")' > scratch.ts
|
||||||
|
jq '.scripts = { start: "ts-node-dev --respawn scratch.ts" }' package.json > tmp.json
|
||||||
|
rm package.json
|
||||||
|
mv tmp.json package.json
|
||||||
|
else
|
||||||
|
cd "$(pwd)/$DATE"
|
||||||
|
fi
|
||||||
|
# Start editor session
|
||||||
|
# tmux new-session \; \
|
||||||
|
# send-keys 'vim scratch.ts' C-m \; \
|
||||||
|
# split-window -v \; \
|
||||||
|
# send-keys 'yarn start' C-m \;
|
||||||
|
}
|
||||||
|
|
49
.config/scripts/thumb.sh
Executable file
49
.config/scripts/thumb.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function thumb() {
|
||||||
|
echo "USING GPU!!!"
|
||||||
|
UUID=$(uuidgen)
|
||||||
|
GRID_X=2
|
||||||
|
GRID_Y=4
|
||||||
|
TMP_FILE_LOCATION="./tmp_chapters_out_$UUID.mp4"
|
||||||
|
|
||||||
|
echo "Removing blank frames..."
|
||||||
|
|
||||||
|
ffmpeg \
|
||||||
|
-hide_banner \
|
||||||
|
-i "$1" \
|
||||||
|
-c:a copy \
|
||||||
|
-vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi \
|
||||||
|
-vf "blackframe=0,metadata=select:key=lavfi.blackframe.pblack:value=15:function=less,format=nv12|vaapi,hwupload" \
|
||||||
|
"$TMP_FILE_LOCATION"
|
||||||
|
|
||||||
|
echo "Getting frame rate..."
|
||||||
|
# Get frame rate
|
||||||
|
FRAMES=$(ffprobe \
|
||||||
|
-loglevel quiet \
|
||||||
|
-select_streams v:0 \
|
||||||
|
-count_packets \
|
||||||
|
-show_entries stream=nb_read_packets \
|
||||||
|
-of csv=p=0 "$TMP_FILE_LOCATION"
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Total frames: $FRAMES"
|
||||||
|
|
||||||
|
GRID_TOTAL=$((GRID_X*GRID_Y))
|
||||||
|
SPLICE=$(((FRAMES + GRID_TOTAL - 1) / GRID_TOTAL))
|
||||||
|
echo "Splicing every: $SPLICE"
|
||||||
|
|
||||||
|
echo "Generating thumbnail grid..."
|
||||||
|
# Generate for frame rate
|
||||||
|
ffmpeg \
|
||||||
|
-hide_banner \
|
||||||
|
-loglevel quiet \
|
||||||
|
-i "$TMP_FILE_LOCATION" \
|
||||||
|
-vf "select=not(mod(n\,$SPLICE)),scale=800:-1,tile=$GRID_X\x$GRID_Y" \
|
||||||
|
-vsync 0 \
|
||||||
|
"chapters-$UUID-gpu.jpg"
|
||||||
|
|
||||||
|
rm "$TMP_FILE_LOCATION"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
57
.config/scripts/webhook.sh
Executable file
57
.config/scripts/webhook.sh
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
REQUESTED_USER=''
|
||||||
|
NAME='Webhook'
|
||||||
|
PIC=''
|
||||||
|
MSG=''
|
||||||
|
ENDPOINT='_'
|
||||||
|
FILE='_'
|
||||||
|
|
||||||
|
getUser() {
|
||||||
|
/usr/local/bin/gsed -nE "/^\[$REQUESTED_USER\]$/{:l n;/^(\[.*\])?$/q;p;bl}" ~/.config/webhook > /tmp/webhook_config.sh ||
|
||||||
|
sed -nE "/^\[$REQUESTED_USER\]$/{:l n;/^(\[.*\])?$/q;p;bl}" ~/.config/webhook > /tmp/webhook_config.sh;
|
||||||
|
chmod +x /tmp/webhook_config.sh
|
||||||
|
. /tmp/webhook_config.sh
|
||||||
|
rm /tmp/webhook_config.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
printUsage() {
|
||||||
|
echo ""
|
||||||
|
echo "Discord Webhook Wrapper"
|
||||||
|
echo "-c Requested premade config to use"
|
||||||
|
echo "-n Username to use"
|
||||||
|
echo "-p Picture to use"
|
||||||
|
echo "-m Message to send"
|
||||||
|
echo "-e Endpoint to hit"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
while getopts 'c:n:p:m:e:f:h' flag; do
|
||||||
|
case "${flag}" in
|
||||||
|
c) REQUESTED_USER="${OPTARG}"; getUser ;;
|
||||||
|
n) NAME="${OPTARG}" ;;
|
||||||
|
p) PIC="${OPTARG}" ;;
|
||||||
|
m) MSG="${OPTARG}" ;;
|
||||||
|
e) ENDPOINT="${OPTARG}" ;;
|
||||||
|
f) FILE="${OPTARG}" ;;
|
||||||
|
*) printUsage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$ENDPOINT" == "_" ]]; then
|
||||||
|
echo "Please provide an endpoint url with -e"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
if [[ "$FILE" == "_" ]]; then
|
||||||
|
curl -i \
|
||||||
|
-H "Accept: multipart/form-data" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-F "payload_json={\"content\": \"$MSG\", \"username\": \"$NAME\", \"avatar_url\": \"$PIC\"}" \
|
||||||
|
"$ENDPOINT" > /dev/null 2>&1;
|
||||||
|
else
|
||||||
|
curl -i \
|
||||||
|
-F "file1=@${FILE}" \
|
||||||
|
-H "Accept: multipart/form-data" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-F "payload_json={\"content\": \"$MSG\", \"username\": \"$NAME\", \"avatar_url\": \"$PIC\"}" \
|
||||||
|
"$ENDPOINT" > /dev/null 2>&1;
|
||||||
|
fi
|
||||||
|
fi
|
137
.zshrc
Normal file
137
.zshrc
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
# Path
|
||||||
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
|
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin"
|
||||||
|
export ANDROID_SDK_ROOT=/Users/$USER/Library/Android/sdk
|
||||||
|
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
alias date=gdate;
|
||||||
|
alias twtxt="AWS_PROFILE=personal twtxt -c .config/twtxt/config"
|
||||||
|
eval "$(rbenv init - zsh)"
|
||||||
|
|
||||||
|
if [[ $(uname -m) == 'arm64' ]]; then
|
||||||
|
# Homebrew has a different location on M series devices
|
||||||
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
export PATH="${PATH}:${HOME}/.local/bin:/usr/local/sbin:${HOME}/.local/share/gem/ruby/2.0.0/bin:/usr/local/bin"
|
||||||
|
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
|
||||||
|
fi
|
||||||
|
|
||||||
|
export CONFIGDIR="${HOME}/.config"
|
||||||
|
export XDG_CONFIG_HOME=$CONFIGDIR
|
||||||
|
export EDITOR=nvim
|
||||||
|
|
||||||
|
export ZSH_DIR="$CONFIGDIR/oh-my-zsh"
|
||||||
|
export ZSH_CUSTOM="$ZSH_DIR/custom"
|
||||||
|
|
||||||
|
export TERM=xterm-256color
|
||||||
|
|
||||||
|
# Text colours
|
||||||
|
export BLACK_TEXT="\033[30m"
|
||||||
|
export RED_TEXT="\033[31m"
|
||||||
|
export GREEN_TEXT="\033[32m"
|
||||||
|
export ORANGE_TEXT="\033[33m"
|
||||||
|
export BLUE_TEXT="\033[34m"
|
||||||
|
export MAGENTA_TEXT="\033[35m"
|
||||||
|
export CYAN_TEXT="\033[36m"
|
||||||
|
export LIGHT_GREY_TEXT="\033[37m"
|
||||||
|
export DEFAULT_TEXT="\033[39m"
|
||||||
|
|
||||||
|
# Background colours
|
||||||
|
export BLACK_BACKGROUND="\033[40m"
|
||||||
|
export RED_BACKGROUND="\033[41m"
|
||||||
|
export GREEN_BACKGROUND="\033[42m"
|
||||||
|
export ORANGE_BACKGROUND="\033[43m"
|
||||||
|
export BLUE_BACKGROUND="\033[44m"
|
||||||
|
export MAGENTA_BACKGROUND="\033[45m"
|
||||||
|
export CYAN_BACKGROUND="\033[46m"
|
||||||
|
export LIGHT_GREY_BACKGROUND="\033[47m"
|
||||||
|
export DEFAULT_BACKGROUND="\033[49m"
|
||||||
|
|
||||||
|
# oh-my-zsh
|
||||||
|
export ZSH="$CONFIGDIR/oh-my-zsh"
|
||||||
|
plugins=(git-prompt git zsh-autosuggestions)
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
|
||||||
|
# Use NVIM
|
||||||
|
alias vim=nvim
|
||||||
|
|
||||||
|
# NVM
|
||||||
|
export NVM_DIR="$CONFIGDIR/nvm"
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||||
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||||
|
|
||||||
|
# Autocomplete
|
||||||
|
ZSH_AUTOSUGGEST_USE_ASYNC=true
|
||||||
|
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
||||||
|
|
||||||
|
# Prompt
|
||||||
|
function precmd {
|
||||||
|
PROMPT="[%c] "
|
||||||
|
RPROMPT="$(git_super_status)"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Added by serverless binary installer
|
||||||
|
export PATH="$HOME/.serverless/bin:$PATH"
|
||||||
|
|
||||||
|
# tabtab source for packages
|
||||||
|
# uninstall by removing these lines
|
||||||
|
[[ -f ~/.config/tabtab/__tabtab.zsh ]] && . ~/.config/tabtab/__tabtab.zsh || true
|
||||||
|
|
||||||
|
# Nodejs
|
||||||
|
export SKIP_PREFLIGHT_CHECK=true
|
||||||
|
|
||||||
|
# FZF
|
||||||
|
export FZF_DEFAULT_COMMAND='find . -type d \( -name Pods -o -name .yarn -o -name node_modules -o -name .git -o -path name \) -prune -false -o -name "*"'
|
||||||
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||||
|
|
||||||
|
# Better dig
|
||||||
|
source ~/.config/scripts/dig.sh
|
||||||
|
|
||||||
|
# Scratchpad command
|
||||||
|
source ~/.config/scripts/scratch.sh
|
||||||
|
|
||||||
|
# Encrypt Files
|
||||||
|
source ~/.config/scripts/encrypt.sh
|
||||||
|
|
||||||
|
# Thumb
|
||||||
|
source ~/.config/scripts/thumb.sh
|
||||||
|
|
||||||
|
# Compress
|
||||||
|
source ~/.config/scripts/compress.sh
|
||||||
|
|
||||||
|
# Ripgrep fzf
|
||||||
|
source ~/.config/scripts/rg_fzf.sh
|
||||||
|
|
||||||
|
# AWS Profile fzf
|
||||||
|
source ~/.config/scripts/aws-profile.sh
|
||||||
|
|
||||||
|
# Kill commands
|
||||||
|
source ~/.config/scripts/kill.sh
|
||||||
|
|
||||||
|
# thefuck
|
||||||
|
eval $(thefuck --alias)
|
||||||
|
alias a=fuck
|
||||||
|
|
||||||
|
# Better Git
|
||||||
|
function git() {
|
||||||
|
case $* in
|
||||||
|
rebase* ) HUSKY_SKIP_HOOKS=1 command git "$@";;
|
||||||
|
* ) command git "$@"
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
source ~/.config/scripts/git_fzf.sh
|
||||||
|
|
||||||
|
# The next line updates PATH for the Google Cloud SDK.
|
||||||
|
if [ -f '/Users/noah/Downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/noah/Downloads/google-cloud-sdk/path.zsh.inc'; fi
|
||||||
|
|
||||||
|
# The next line enables shell command completion for gcloud.
|
||||||
|
if [ -f '/Users/noah/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/noah/Downloads/google-cloud-sdk/completion.zsh.inc'; fi
|
||||||
|
[ -f "/Users/noah/.ghcup/env" ] && source "/Users/noah/.ghcup/env" # ghcup-env
|
||||||
|
|
||||||
|
# bun completions
|
||||||
|
[ -s "/Users/noah/.bun/_bun" ] && source "/Users/noah/.bun/_bun"
|
||||||
|
|
||||||
|
# bun
|
||||||
|
export BUN_INSTALL="$HOME/.bun"
|
||||||
|
export PATH="$BUN_INSTALL/bin:$PATH"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user