# 使用 Homebrew, apk, chocolatey, apt, MacPorts, Nix, pacman, zypper, scoop, winget 安装 kubectx

查看 kubectx 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:kubectx
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install kubectx
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install kubectx
```

  证据: MacPorts ports tree: sysutils/kubectx/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add kubectx
```

  证据: Alpine Linux edge package indexes: kubectx from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install kubectx
```

  证据: Debian stable package indexes: kubectx from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- Nix (92%):

```sh
nix profile install nixpkgs#kubectx
```

  证据: nixpkgs package indexes: pkgs/by-name/ku/kubectx/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S kubectx
```

  证据: Arch Linux sync databases: kubectx from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install kubectx
```

  证据: openSUSE Tumbleweed package metadata: kubectx from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

### Windows

- Chocolatey (92%):

```sh
choco install kubectx
```

  证据: Chocolatey community package catalog: kubectx from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','kindle'

- Scoop (92%):

```sh
scoop install main/kubectx
```

  证据: Scoop official bucket manifest trees: bucket/kubectx.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

- winget (92%):

```sh
winget install --id ahmetb.kubectx -e
```

  证据: Windows Package Manager source index: ahmetb.kubectx from https://cdn.winget.microsoft.com/cache/source.msix

## 软件包事实

- **软件包键:** brew:kubectx
- **软件包管理器:** Homebrew
- **版本:** 0.11.0
- **来源摘要:** Tool that can switch between kubectl contexts easily and create aliases
- **主页:** <https://github.com/ahmetb/kubectx>
- **仓库:** <https://github.com/ahmetb/kubectx>
- **最后更新:** 2026-07-27T21:58:45+02:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- kubectl-ctx (别名)
- kubectl-ns (别名)
- kubectx (别名)
- kubens (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 0.11.0
## 项目历史与用法

kubectx is a small Kubernetes command-line companion that packages two everyday workflow shortcuts: switching kubeconfig contexts with kubectx and switching namespaces with kubens. It became a widely installed kubectl-adjacent utility because it solves a repetitive operator problem without introducing a larger cluster-management framework.

### 项目历史

The public GitHub repository was created on March 30, 2017, and the v0.1 release was published on April 25, 2017. The original project was shell-oriented; later releases added a Go implementation while retaining the simple command names and shell-completion focused workflow.

The README describes the package as 'Power tools for kubectl' and positions kubectx for faster cluster/context changes and kubens for namespace changes. That pairing made the project fit naturally beside kubectl rather than replacing it.

### 采用历史

kubectx spread through multiple packaging ecosystems because it is useful on every workstation that touches more than one Kubernetes cluster. The official README documents installation through Homebrew, MacPorts, apt, pacman, Chocolatey, Scoop, winget, and Krew, which reflects cross-platform adoption by both Kubernetes operators and developers.

Its inclusion as Krew plugins named ctx and ns gave it a Kubernetes-native installation path, while Homebrew and Linux distribution packages made it familiar to package-manager users outside the Kubernetes plugin index.

### 使用方式

kubectx reads the user's kubeconfig contexts and switches the active context, including a shortcut for returning to the previous context. kubens similarly updates the namespace on the active context. Optional fzf integration adds interactive selection for long cluster and namespace lists.

The tool is commonly paired with shell completions and prompt helpers such as kube-ps1 or oh-my-posh so operators can both switch context quickly and see the selected cluster or namespace before running kubectl commands.

### 为什么软件包爱好者会关心

kubectx is a package-nerd staple because it is tiny, scriptable, and heavily repackaged: one upstream repository feeds native OS package managers, Windows package managers, and Krew. It is also a good example of a CLI whose adoption comes from reducing command friction rather than adding a new control plane.

### 时间线

- 2017-03-30: Public GitHub repository created
- 2017-04-25: v0.1 release published
- 2021-07-06: v0.9.4 release published after the project had become a common kubectl companion
- 2026-03-27: v0.11.0 release published

### Related projects

- kubens is shipped from the same repository and handles namespace switching.
- Krew distributes kubectx and kubens as kubectl plugins named ctx and ns.
- fzf is an optional dependency for interactive context and namespace selection.
- kube-ps1 and oh-my-posh are prompt tools the README recommends for displaying Kubernetes context.

### 来源

- <https://api.github.com/repos/ahmetb/kubectx>
- <https://formulae.brew.sh/formula/kubectx>
- <https://github.com/ahmetb/kubectx>
- <https://github.com/ahmetb/kubectx/releases>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals


## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: ~/.kube/config
## 其他软件包管理器记录

- Debian apt - kubectx - 0.9.5-2+b10: normalized package name match | Debian stable package indexes: kubectx from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Fast way to switch between clusters and namespaces in kubectl | https://github.com/ahmetb/kubectx
- Nix - kubectx: normalized package name match | nixpkgs package indexes: pkgs/by-name/ku/kubectx/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- Ubuntu apt - kubectx - 0.9.5-1: normalized package name match | Ubuntu 24.04 LTS package indexes: kubectx from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | Fast way to switch between clusters and namespaces in kubectl | https://github.com/ahmetb/kubectx
- apk - kubectx - 0.11.0-r3: normalized package name match | Alpine Linux edge package indexes: kubectx from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Faster way to switch between clusters and namespaces in kubectl | https://kubectx.dev/
- apk - kubectx-bash-completion - 0.11.0-r3: normalized package name match | Alpine Linux edge package indexes: kubectx-bash-completion from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Bash completions for kubectx | https://kubectx.dev/
- apk - kubectx-fish-completion - 0.11.0-r3: normalized package name match | Alpine Linux edge package indexes: kubectx-fish-completion from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Fish completions for kubectx | https://kubectx.dev/
- apk - kubectx-zsh-completion - 0.11.0-r3: normalized package name match | Alpine Linux edge package indexes: kubectx-zsh-completion from https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz | Zsh completions for kubectx | https://kubectx.dev/
- pacman - kubectx - 0.11.0-1: normalized package name match | Arch Linux sync databases: kubectx from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | Utility to manage and switch between kubectl contexts and Kubernetes namespaces | https://github.com/ahmetb/kubectx
- zypper - kubectx - 0.11.0-1.5: normalized package name match | openSUSE Tumbleweed package metadata: kubectx from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | Faster way to switch between clusters and namespaces in kubectl | https://github.com/ahmetb/kubectx
- zypper - kubectx-bash-completion - 0.11.0-1.5: normalized package name match | openSUSE Tumbleweed package metadata: kubectx-bash-completion from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | Bash Completion for kubectx | https://github.com/ahmetb/kubectx
- zypper - kubectx-fish-completion - 0.11.0-1.5: normalized package name match | openSUSE Tumbleweed package metadata: kubectx-fish-completion from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | Fish Completion for kubectx | https://github.com/ahmetb/kubectx
- zypper - kubectx-zsh-completion - 0.11.0-1.5: normalized package name match | openSUSE Tumbleweed package metadata: kubectx-zsh-completion from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | Zsh Completion for kubectx | https://github.com/ahmetb/kubectx
- MacPorts - kubectx: normalized package name match | MacPorts ports tree: sysutils/kubectx/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Chocolatey - kubectx: normalized package name match | Chocolatey community package catalog: kubectx from http://community.chocolatey.org/api/v2/Packages?$filter=IsLatestVersion&$select=Id&$top=1000&$skiptoken='11','kindle'
- Scoop - main/kubectx: normalized package name match | Scoop official bucket manifest trees: bucket/kubectx.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1
- winget - ahmetb.kubectx: normalized package name match | Windows Package Manager source index: ahmetb.kubectx from https://cdn.winget.microsoft.com/cache/source.msix


## Combined YAML source

View the package source record on GitHub. [combined/kubectx.yml](https://github.com/mxcl/pkgdb/blob/main/combined/kubectx.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
