Skip to content

Instantly share code, notes, and snippets.

@mrnkr
Last active June 10, 2026 14:31
Show Gist options
  • Select an option

  • Save mrnkr/69067d217caa1afda798bea47d9d76ae to your computer and use it in GitHub Desktop.

Select an option

Save mrnkr/69067d217caa1afda798bea47d9d76ae to your computer and use it in GitHub Desktop.
My zsh aliases
alias intel="arch -x86_64"
# kubectl shortcuts to use fzf to search resources
alias kctx='kubectl config use-context $(kubectl config get-contexts | fzf | tr -s " " | cut -d " " -f 2)'
klogs() {
if [ -n "$1" ]; then
kubectl logs -n "$1" -f $(kubectl get pods -n "$1" | fzf | tr -s " " | cut -d " " -f 1)
else
selection=$(kubectl get pods --all-namespaces | fzf | tr -s " ")
[ -z "$selection" ] && return
namespace=$(echo "$selection" | cut -d " " -f 1)
pod_name=$(echo "$selection" | cut -d " " -f 2)
kubectl logs -n "$namespace" -f "$pod_name"
fi
}
krails() {
if [ -n "$1" ]; then
kubectl exec -n "$1" -it $(kubectl get pods -n "$1" | fzf | tr -s " " | cut -d " " -f 1) -- env TEMPORAL_METRICS_ENABLED=false FUZION_TEMPORAL_METRICS_ENABLED=false bundle exec rails console
else
selection=$(kubectl get pods --all-namespaces | fzf | tr -s " ")
[ -z "$selection" ] && return
namespace=$(echo "$selection" | cut -d " " -f 1)
pod_name=$(echo "$selection" | cut -d " " -f 2)
kubectl exec -n "$namespace" -it "$pod_name" -- env TEMPORAL_METRICS_ENABLED=false FUZION_TEMPORAL_METRICS_ENABLED=false bundle exec rails console
fi
}
kenv() {
if [ -n "$1" ]; then
kubectl exec -n "$1" -it $(kubectl get pods -n "$1" | fzf | tr -s " " | cut -d " " -f 1) -- env
else
selection=$(kubectl get pods --all-namespaces | fzf | tr -s " ")
[ -z "$selection" ] && return
namespace=$(echo "$selection" | cut -d " " -f 1)
pod_name=$(echo "$selection" | cut -d " " -f 2)
kubectl exec -n "$namespace" -it "$pod_name" -- env
fi
}
# kubectl restart
alias krestart='kubectl rollout restart deployment/$(kubectl get deployments | fzf | tr -s " " | cut -d " " -f 1)'
# better rspec
rspec-lean() {
setopt local_options pipefail
bundle exec rspec -fd --force-color "$@" | awk -v root="$(pwd)/" '
/\/gems\// || /\.rbenv\// || /\/ruby\// || /\/bundler\// { next }
/^[a-zA-Z0-9_-]+ \([0-9]+\.[0-9]+/ { next }
{
gsub(/\[[^]]*\]/, "")
while ((i = index($0, root)) > 0) {
$0 = substr($0, 1, i-1) "" substr($0, i + length(root))
}
print
fflush()
}
' | tee /tmp/rspec.last.out
}
rspec-explain() {
local prompt="${*:-explain the rspec failures, focus on root cause, look only at the provided rspec output}"
local input; input=$(mktemp)
sed -E $'/\x1b\\[[0-9;]*32m/d; /^request_base_url=/d; /^request_id=/d; /^method=(GET|POST|PUT|PATCH|DELETE) /d; s/\x1b\\[[0-9;]*m//g' /tmp/rspec.last.out > "$input"
if [[ ! -s "$input" ]]; then
echo "nothing left after filtering green lines" >&2
rm -f "$input"; return 0
fi
echo "feeding $(wc -c < "$input") bytes to claude…" >&2
local out; out=$(mktemp)
local chars=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
trap 'printf "\r\e[K" >&2; kill $pid 2>/dev/null; rm -f "$out" "$input"; return 130' INT
(claude -p "$prompt" < "$input" > "$out") &
local pid=$!
local i=1
while kill -0 $pid 2>/dev/null; do
printf '\r\e[36m%s\e[0m thinking…' "${chars[i]}" >&2
i=$(( i % ${#chars[@]} + 1 ))
sleep 0.1
done
wait $pid
printf '\r\e[K' >&2
trap - INT
cat "$out"
rm -f "$out" "$input"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment