feat manage script
This commit is contained in:
97
config/shared/bin/colortest
Executable file
97
config/shared/bin/colortest
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Test black and white
|
||||
echo "=== Black and White ==="
|
||||
printf "Normal text\n"
|
||||
printf "\e[1mBold text\e[0m\n"
|
||||
printf "\e[7mReverse text\e[0m\n\n"
|
||||
|
||||
# Test 4-bit ANSI (16 colors)
|
||||
echo "=== 4-bit ANSI Colors (16 colors) ==="
|
||||
echo "Foreground colors:"
|
||||
for i in {30..37}; do
|
||||
printf "\e[${i}m\\e[${i}m\e[0m "
|
||||
done
|
||||
echo -e "\n"
|
||||
|
||||
echo "Background colors:"
|
||||
for i in {40..47}; do
|
||||
printf "\e[${i}m\\e[${i}m\e[0m "
|
||||
done
|
||||
echo -e "\n"
|
||||
|
||||
echo "Bright foreground colors:"
|
||||
for i in {90..97}; do
|
||||
printf "\e[${i}m\\e[${i}m\e[0m "
|
||||
done
|
||||
echo -e "\n"
|
||||
|
||||
echo "Bright background colors:"
|
||||
for i in {100..107}; do
|
||||
printf "\e[${i}m\\e[${i}m\e[0m "
|
||||
done
|
||||
echo -e "\n\n"
|
||||
|
||||
# Test 8-bit ANSI (256 colors)
|
||||
echo "=== 8-bit ANSI Colors (256 colors) ==="
|
||||
echo "16 System Colors:"
|
||||
for i in {0..15}; do
|
||||
printf "\e[48;5;${i}m \e[0m"
|
||||
if [ $((($i + 1) % 8)) == 0 ]; then
|
||||
echo
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
echo "216 RGB Colors:"
|
||||
for i in {16..231}; do
|
||||
printf "\e[48;5;${i}m \e[0m"
|
||||
if [ $((($i - 15) % 36)) == 0 ]; then
|
||||
echo
|
||||
fi
|
||||
done
|
||||
echo
|
||||
|
||||
echo "24 Grayscale Colors:"
|
||||
for i in {232..255}; do
|
||||
printf "\e[48;5;${i}m \e[0m"
|
||||
if [ $((($i - 231) % 12)) == 0 ]; then
|
||||
echo
|
||||
fi
|
||||
done
|
||||
echo -e "\n"
|
||||
|
||||
# Test 24-bit true color
|
||||
echo "=== 24-bit True Color (16.7 million colors) ==="
|
||||
echo "RGB Color Gradient:"
|
||||
awk 'BEGIN{
|
||||
s="/\\";
|
||||
for (colnum = 0; colnum<77; colnum++) {
|
||||
r = 255-(colnum*255/76);
|
||||
g = (colnum*510/76);
|
||||
b = (colnum*255/76);
|
||||
if (g>255) g = 510-g;
|
||||
printf "\033[48;2;%d;%d;%dm", r,g,b;
|
||||
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
|
||||
printf "%s\033[0m", substr(s,colnum%2+1,1);
|
||||
}
|
||||
printf "\n";
|
||||
}'
|
||||
|
||||
echo "RGB Color Bars:"
|
||||
for r in 0 127 255; do
|
||||
for g in 0 127 255; do
|
||||
for b in 0 127 255; do
|
||||
printf "\e[48;2;${r};${g};${b}m \e[0m"
|
||||
done
|
||||
printf " "
|
||||
done
|
||||
echo
|
||||
done
|
||||
echo
|
||||
|
||||
# Print terminal information
|
||||
echo "=== Terminal Information ==="
|
||||
echo "TERM: $TERM"
|
||||
echo "COLORTERM: $COLORTERM"
|
||||
echo "Reported colors (tput colors): $(tput colors)"
|
||||
18
config/shared/bin/detect_keys
Executable file
18
config/shared/bin/detect_keys
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/zsh
|
||||
|
||||
echo "Press any key combination. Press Ctrl+C to exit."
|
||||
while true; do
|
||||
result=""
|
||||
escape_sequence=""
|
||||
read -sk 1 key
|
||||
if [[ $key == $'\x1b' ]]; then
|
||||
escape_sequence+="^["
|
||||
while read -sk 1 -t 0.01 next_key; do
|
||||
escape_sequence+="$next_key"
|
||||
done
|
||||
result="$escape_sequence"
|
||||
else
|
||||
result="$key"
|
||||
fi
|
||||
echo -E "Key: $result"
|
||||
done
|
||||
41
config/shared/bin/dev
Executable file
41
config/shared/bin/dev
Executable file
@@ -0,0 +1,41 @@
|
||||
# --rm: automatically remove the container when it exits
|
||||
|
||||
# Check if a container name was provided
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <container_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMAGE="web-stack"
|
||||
NAME="${IMAGE}-$1"
|
||||
|
||||
# Function to exec into the container
|
||||
exec_into_container() {
|
||||
docker exec --detach-keys "ctrl-q,ctrl-p" -it $NAME /bin/zsh
|
||||
}
|
||||
|
||||
# Check if the container exists
|
||||
if [ "$(docker ps -a -q -f name=$NAME)" ]; then
|
||||
# Container exists, start it if it's not running
|
||||
if [ ! "$(docker ps -q -f name=$NAME)" ]; then
|
||||
echo "Container $NAME exists but is not running. Starting it..."
|
||||
docker start $NAME
|
||||
else
|
||||
echo "Container $NAME is already running."
|
||||
fi
|
||||
else
|
||||
echo "Container $NAME does not exist. Creating and running it in detached mode..."
|
||||
docker run -d \
|
||||
--detach-keys "ctrl-q,ctrl-p" \
|
||||
--network host \
|
||||
-v $HOME/.ssh:/home/dev/.ssh \
|
||||
-v $PWD:/workspace \
|
||||
--name $NAME \
|
||||
--init \
|
||||
$IMAGE \
|
||||
tail -f /dev/null
|
||||
fi
|
||||
|
||||
# Exec into the container
|
||||
echo "Executing into container $NAME..."
|
||||
exec_into_container
|
||||
29
config/shared/bin/ssh-forward
Executable file
29
config/shared/bin/ssh-forward
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to display usage information
|
||||
usage() {
|
||||
echo "Usage: $0 <user@host> <port1> [port2] [port3] ..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Ensure at least two arguments are provided: host and one port
|
||||
if [ "$#" -lt 2 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
# Extract the host from the first argument
|
||||
HOST="$1"
|
||||
shift # Shift the arguments so that $@ contains the remaining ports
|
||||
|
||||
# Initialize the PORTS variable
|
||||
PORTS=""
|
||||
|
||||
# Iterate over the remaining arguments, which are the ports
|
||||
for port in "$@"; do
|
||||
PORTS="$PORTS -L ${port}:localhost:${port}"
|
||||
done
|
||||
|
||||
# Construct and run the SSH command
|
||||
SSH_CMD="ssh -N -T -o ExitOnForwardFailure=yes $HOST $PORTS"
|
||||
echo "Running: $SSH_CMD"
|
||||
$SSH_CMD
|
||||
Reference in New Issue
Block a user