GitHub - n-wen/k8s_tool: autohotkey script for kubectl command

2 min read Original article ↗

Kubernetes AutoHotkey Tool

English | 中文

A powerful AutoHotkey script that provides quick shortcuts and GUI interface for common Kubernetes operations.

Features

Text Shortcuts

Quick text expansion shortcuts for common kubectl commands:

  • @ksetns - Set namespace
  • @kgetns - Get current namespace
  • @kpod - Get pods
  • @kdep - Get deployments
  • @kns - Get all namespaces
  • @klog - View pod logs (uses clipboard content as pod name)
  • @krestart - Restart deployment
  • @ksetimg - Set deployment image

GUI Command Selector

Press Ctrl+Shift+K to open the Kubernetes Commander GUI with:

  • Namespace management (set, view, edit current namespace)
  • Dropdown menu with all available commands
  • Visual interface for easier command selection
  • Context-aware command execution

Installation

  1. Install AutoHotkey v2.0 or later
  2. Download the kubectl_tool.ahk script
  3. Double-click the script file to run it
  4. The script will run in the background and provide shortcuts

Usage

Using Text Shortcuts

  1. Type any shortcut (e.g., @kpod) in any text field
  2. The shortcut will automatically expand to the corresponding kubectl command
  3. For commands requiring pod/deployment names, copy the name to clipboard first

Using GUI Interface

  1. Press Ctrl+Shift+K to open Kubernetes Commander
  2. Set your preferred namespace (optional)
  3. Select a command from the dropdown menu
  4. Click "execute" to run the command

Namespace Management

The tool maintains a global namespace context:

  • Commands automatically include -n <namespace> when a namespace is set
  • You can change namespace anytime through the GUI or @ksetns shortcut
  • View current namespace with @kgetns or through the GUI

Command Examples

Shortcut Generated Command Description
@kpod kubectl get pods List all pods
@kpod (with namespace) kubectl get pods -n <namespace> List pods in namespace
@klog kubectl logs -f --tail 200 <clipboard> Follow logs of pod from clipboard
@krestart kubectl rollout restart deployment Restart deployment (cursor positioned for name input)

Requirements

  • AutoHotkey v2.0 or later
  • kubectl installed and configured
  • Windows operating system

Configuration

The script stores the current namespace in a global variable that persists during the session. No additional configuration files are needed.

Contributing

Feel free to submit issues and enhancement requests!

License

This project is open source and available under standard terms.