refactor: clean up and rename binaries

This commit is contained in:
Tomas Mirchev 2025-11-03 06:03:25 +02:00
parent 60834ccae1
commit 34b6439521
9 changed files with 40 additions and 204 deletions

View File

@ -1,135 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
ATTACH_TMUX=1
DRY_RUN=0
TMUX_SESSION_DEFAULT="default"
df_platform=""
df_namespace=""
df_user=""
ssh_identity=""
ssh_host=""
ssh_args=()
usage() {
local prog
prog=$(basename "$0")
echo "Usage: $prog <platform> [user@]namespace [--no-tmux|-t] [--dry-run|-n] [-- <ssh args...>]" >&2
echo
echo "Examples:"
echo " $prog orb namespace"
echo " $prog utm user@namespace --no-tmux"
echo " $prog core user@namespace --dry-run -- -v -p 2222"
exit 1
}
parse_args() {
if [[ $# -lt 2 ]]; then
usage
fi
df_platform="$1"
local user_namespace_arg="$2"
shift 2
# Extract df_user and df_namespace
if [[ "$user_namespace_arg" == *@* ]]; then
df_user="${user_namespace_arg%@*}"
df_namespace="${user_namespace_arg#*@}"
else
df_user="$USER"
df_namespace="$user_namespace_arg"
fi
# Parse remaining flags and ssh args
while [[ $# -gt 0 ]]; do
case "$1" in
-t|--no-tmux)
ATTACH_TMUX=0
shift
;;
-n|--dry-run)
DRY_RUN=1
shift
;;
--)
shift
ssh_args+=("$@")
break
;;
*)
echo "Unknown option: $1" >&2
usage
;;
esac
done
}
resolve_host() {
case "$df_platform" in
orb)
# orb-stack handles user@namespace internally
ssh_host="${df_namespace}@orb"
;;
utm)
ssh_host="${df_namespace}.utm.local"
ssh_identity="$HOME/.ssh/id_ed25519_internal"
;;
core)
ssh_host="${df_namespace}.core.lan"
ssh_identity="$HOME/.ssh/id_ed25519_internal"
;;
ec2)
ssh_host="${df_namespace}.ec2.internal"
;;
hetzner)
ssh_host="${df_namespace}.hetzner.test"
;;
*)
echo "Error: unknown platform '$df_platform'" >&2
exit 1
;;
esac
}
build_ssh_cmd() {
local cmd=(ssh -tt)
if [[ -n "$ssh_identity" ]]; then
cmd+=(-i "$ssh_identity" -o IdentitiesOnly=yes)
fi
if [[ ${#ssh_args[@]} -gt 0 ]]; then
cmd+=("${ssh_args[@]}")
fi
cmd+=("${df_user}@${ssh_host}")
if [[ $ATTACH_TMUX -eq 1 ]]; then
cmd+=("tmux" "new-session" "-As" "$TMUX_SESSION_DEFAULT"
"-e" "DF_NAMESPACE=$df_namespace"
"-e" "DF_PLATFORM=$df_platform")
fi
echo "${cmd[@]}"
}
main() {
parse_args "$@"
resolve_host
ssh_cmd=($(build_ssh_cmd))
if [[ $DRY_RUN -eq 1 ]]; then
echo "Dry run command:"
printf '%q ' "${ssh_cmd[@]}"
echo
exit 0
fi
exec "${ssh_cmd[@]}"
}
main "$@"

View File

@ -1,18 +0,0 @@
#!/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

39
config/shared/bin/sync-theme Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
declare -A THEME=(
["ghostty.url"]="https://raw.githubusercontent.com/triimdev/invero.nvim/refs/heads/main/extras/ghostty/invero_day"
["ghostty.dir"]="$HOME/.config/ghostty/themes"
["ghostty.name"]="Invero Day"
["wezterm.url"]="https://raw.githubusercontent.com/triimdev/invero.nvim/refs/heads/main/extras/wezterm/invero_day.toml"
["wezterm.dir"]="$HOME/.config/wezterm/colors"
["wezterm.name"]="Invero Day.toml"
)
theme="${1:-}"
if [[ -z "$theme" ]]; then
echo "Usage: $0 <theme>"
echo "Available themes: $(printf '%s\n' "${!THEME[@]}" | cut -d. -f1 | sort -u | tr '\n' ' ')"
exit 1
fi
if [[ -z "${THEME[$theme.url]+x}" ]]; then
echo "Unknown theme '$theme'. Available: $(printf '%s\n' "${!THEME[@]}" | cut -d. -f1 | sort -u | tr '\n' ' ')"
exit 1
fi
url="${THEME[$theme.url]}"
dir="${THEME[$theme.dir]}"
name="${THEME[$theme.name]}"
path="${dir}/${name}"
mkdir -p "$dir"
if curl -fsSL -o "$path" "$url"; then
echo "Theme downloaded to $path"
else
echo "Failed to download theme for '$theme'."
exit 1
fi

View File

@ -1,26 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# URL="https://raw.githubusercontent.com/triimd/invero.nvim/refs/heads/main/extras/ghostty/invero_day"
# THEME_DIR="$HOME/.config/ghostty/themes"
# THEME_NAME="Invero Day"
# URL="https://raw.githubusercontent.com/triimd/invero.nvim/refs/heads/main/extras/wezterm/invero_day.toml"
# THEME_DIR="$HOME/.config/wezterm/colors"
# THEME_NAME="Invero Day.toml"
URL="https://raw.githubusercontent.com/triimd/invero.nvim/refs/heads/main/extras/kitty/invero_day.conf"
THEME_DIR="$HOME/.config/kitty"
THEME_NAME="invero.conf"
THEME_PATH="${THEME_DIR}/${THEME_NAME}"
mkdir -p "$THEME_DIR"
if curl -fsSL -o "$THEME_PATH" "$URL"; then
echo "Theme downloaded to $THEME_PATH"
else
echo "Failed to download theme."
exit 1
fi

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
file=/tmp/vm-switch.txt
# Ensure the file exists
touch "$file"
echo "Listening on $file ..."
tail -n0 -F "$file" | while read vm; do
[ -n "$vm" ] && echo "Switch requested: $vm" && ~/bin/work "$vm" &
done

View File

@ -1,3 +0,0 @@
#!/bin/sh
orbctl list > /tmp/vmlist.txt

View File

@ -1,10 +0,0 @@
#!/bin/sh
# Usage: work <vm>
vm="$1"
if [ -z "$vm" ]; then
echo "Usage: work <vm>"
exit 1
fi
exec vm "${vm}-orb"

@ -1 +1 @@
Subproject commit 8687a1cf31bb6b28d3c234ffb308c25f14c02f52
Subproject commit efa84c2ee390598f24028dd5c1e4f3282accd646