-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scripts folder and fixes for tmux popup
- Loading branch information
1 parent
6d22ebc
commit 93bebc9
Showing
11 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Get the current date and time in the format YYYY-MM-DD_HH-MM-SS | ||
current_date=$(date +"%Y-%m-%d_%H-%M-%S") | ||
|
||
# Define the source and destination directories for scripts | ||
SCRIPTS_DIR="./scripts" # Change this if the new scripts directory is elsewhere | ||
BACKUP_DIR="$HOME/.config-backup-$current_date" | ||
OLD_SCRIPTS_DIR="$HOME/scripts" | ||
|
||
# Create a backup directory | ||
mkdir -p "$BACKUP_DIR" | ||
|
||
# Handle the scripts directory as a special case | ||
if [ -d "$OLD_SCRIPTS_DIR" ]; then | ||
BACKUP_SCRIPTS_DIR="$BACKUP_DIR/.scripts" | ||
|
||
# Backup the old scripts directory | ||
echo "Backing up the old scripts directory to $BACKUP_SCRIPTS_DIR" | ||
mv "$OLD_SCRIPTS_DIR" "$BACKUP_SCRIPTS_DIR" | ||
else | ||
echo "No existing scripts directory found. No backup needed." | ||
fi | ||
|
||
# Copy the new scripts directory if it exists | ||
if [ -d "$SCRIPTS_DIR" ]; then | ||
echo "Copying the new scripts directory from $SCRIPTS_DIR to $OLD_SCRIPTS_DIR" | ||
cp -r "$SCRIPTS_DIR" "$OLD_SCRIPTS_DIR" | ||
else | ||
echo "Error: New scripts directory $SCRIPTS_DIR does not exist." | ||
exit 1 | ||
fi | ||
|
||
echo "Backup and copy for scripts completed successfully." |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Print basic colors (0-7) | ||
echo "Basic Colors (0-7):" | ||
for i in {0..7}; do | ||
printf "\e[3${i}mColor ${i}\e[0m " | ||
done | ||
echo -e "\n" | ||
|
||
# Print bright colors (8-15) | ||
echo "Bright Colors (8-15):" | ||
for i in {0..7}; do | ||
printf "\e[3${i};1mColor $((i + 8))\e[0m " | ||
done | ||
echo -e "\n" | ||
|
||
# Print 256 colors | ||
echo "256 Colors:" | ||
for i in {0..255}; do | ||
printf "\e[38;5;${i}mColor ${i}\e[0m " | ||
# Break line after every 16 colors for better readability | ||
if (((i + 1) % 16 == 0)); then | ||
echo | ||
fi | ||
done | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# | ||
# NOTE: force deleting a namespace should be absolute last resort, | ||
# you want instead to find which resource is holding up the namespace | ||
# and clean that up (vs leaking resources) | ||
# | ||
# First check what is holding up the ns, if it's for instance: | ||
# custom.metrics.k8s.io/v1beta1: the server is currently | ||
# unable to handle the request | ||
# Then: | ||
# k get apiservice v1beta1.custom.metrics.k8s.io | ||
# NAME SERVICE AVAILABLE AGE | ||
# v1beta1.custom.metrics.k8s.io istio-system/prometheus-adapter False (ServiceNotFound) 2d4h | ||
# k delete apiservice v1beta1.custom.metrics.k8s.io | ||
# (though this shouldn't happen: find out why prom didn't unregister...) | ||
# | ||
# (Very) Partially inspired by knsk.sh | ||
# | ||
echo "Checking for stuck namespaces" | ||
NSS=$(kubectl get ns 2>/dev/null | grep Terminating | cut -f1 -d ' ') | ||
if [[ "$NSS" == "" ]]; then | ||
echo "No stuck namespaces found" | ||
exit 0 | ||
fi | ||
# Start kubectl proxy to talk to API server | ||
PORT=8118 | ||
kubectl proxy --port=$PORT & | ||
kp_pid=$! | ||
function cleanup { | ||
kill $kp_pid | ||
echo "Done cleanup. killed $kp_pid." | ||
} | ||
trap cleanup exit | ||
|
||
for NS in $NSS; do | ||
echo "Found stuck namespace: $NS" | ||
kubectl get all -n "$NS" | ||
echo "While this is bad too (leaks resources)," | ||
# kubectl patch svc -n istio-system istio-ingressgateway -p '{"metadata":{"finalizers":null}}' | ||
echo "Did you try to: kubectl patch -p '{\"metadata\":{\"finalizers\":null}}'" | ||
echo "^C now before delete..." | ||
sleep 5 | ||
JSON=$(kubectl get ns "$NS" -o json | jq -r '.spec.finalizers=[]') | ||
curl -X PUT --data-binary "$JSON" -H "Content-Type: application/json" "http://localhost:$PORT/api/v1/namespaces/$NS/finalize" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/zsh | ||
|
||
#! /usr/bin/env bash | ||
|
||
tmux_popup_session_name="_popup" | ||
|
||
if [ "$(tmux display-message -p -F "#{session_name}")" = "${tmux_popup_session_name}" ];then | ||
tmux detach-client | ||
else | ||
tmux popup -d '#{pane_current_path}' -xC -yC -w80% -h80% -E\ | ||
"tmux new-session -A -s ${tmux_popup_session_name}" | ||
fi |