[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4820":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},4820,"kubectx","ahmetb\u002Fkubectx","ahmetb","Faster way to switch between clusters and namespaces in kubectl","https:\u002F\u002Fkubectx.dev",null,"Go",19802,1378,130,37,0,5,14,80,22,44.42,"Apache License 2.0",false,"master",[26,27,28,29],"kubectl","kubectl-plugins","kubernetes","kubernetes-clusters","2026-06-12 02:01:04","# `kubectx` + `kubens`: Power tools for kubectl\n\n![Latest GitHub release](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Frelease\u002Fahmetb\u002Fkubectx.svg)\n![GitHub stars](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fstars\u002Fahmetb\u002Fkubectx.svg?label=github%20stars)\n![Homebrew downloads](https:\u002F\u002Fimg.shields.io\u002Fhomebrew\u002Finstalls\u002Fdy\u002Fkubectx?label=macOS%20installs)\n[![Go implementation (CI)](https:\u002F\u002Fgithub.com\u002Fahmetb\u002Fkubectx\u002Fworkflows\u002FGo%20implementation%20(CI)\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fahmetb\u002Fkubectx\u002Factions?query=workflow%3A\"Go+implementation+(CI)\")\n\nThis repository provides both `kubectx` and `kubens` tools.\n[Install &rarr;](#installation)\n\n## What are `kubectx` and `kubens`?\n\n**kubectx** is a tool to switch between contexts (clusters) on kubectl\nfaster, and launch readonly shells for each context.\u003Cbr\u002F>\n**kubens** is a tool to switch between Kubernetes namespaces (and\nconfigure them for kubectl) easily.\n\nHere's a **`kubectx`** demo:\n![kubectx demo GIF](img\u002Fkubectx-demo.gif)\n\n...and here's a **`kubens`** demo:\n![kubens demo GIF](img\u002Fkubens-demo.gif)\n\n### Usage\n\n#### kubectx\n\nSwitch to another cluster that's in kubeconfig:\n\n```sh\n$ kubectx minikube\nSwitched to context \"minikube\".\n```\n\nSwitch back to previous cluster:\n\n```sh\n$ kubectx -\nSwitched to context \"oregon\".\n```\n\nStart an isolated shell that only has a single context:\n\n```sh\n$ kubectx -s minikube\n```\n\nStart a read-only shell where write operations are blocked:\n\n```sh\n$ kubectx -r minikube\n```\n\nRename context:\n\n```sh\n$ kubectx dublin=gke_ahmetb_europe-west1-b_dublin\nContext \"gke_ahmetb_europe-west1-b_dublin\" renamed to \"dublin\".\n```\n\n#### kubens\n\nChange the active namespace on kubectl:\n\n```sh\n$ kubens kube-system\nContext \"test\" set.\nActive namespace is \"kube-system\".\n```\n\nGo back to the previous namespace:\n\n```sh\n$ kubens -\nContext \"test\" set.\nActive namespace is \"default\".\n```\n\nChange the active namespace even if it doesn't exist:\n\n```sh\n$ kubens namespace-404 -f\nContext \"test\" set.\nActive namespace is \"namespace-404\".\n```\n\nIf you have [`fzf`](https:\u002F\u002Fgithub.com\u002Fjunegunn\u002Ffzf) installed, you can also\n**interactively** select a context or cluster, or fuzzy-search by typing a few\ncharacters. To learn more, read [interactive mode &rarr;](#interactive-mode)\n\nBoth `kubectx` and `kubens` support \u003Ckbd>Tab\u003C\u002Fkbd> completion on bash\u002Fzsh\u002Ffish\nshells to help with long context names. You don't have to remember full context\nnames anymore.\n\n-----\n\n## Installation\n\n| Package manager | Command |\n|---|---|\n| [Homebrew](https:\u002F\u002Fbrew.sh\u002F) (macOS & Linux) | `brew install kubectx` |\n| [MacPorts](https:\u002F\u002Fwww.macports.org) (macOS) | `sudo port install kubectx` |\n| apt (Debian\u002FUbuntu) | `sudo apt install kubectx` |\n| pacman (Arch Linux) | `sudo pacman -S kubectx` |\n| [Chocolatey](https:\u002F\u002Fchocolatey.org\u002F) (Windows) | `choco install kubens kubectx` |\n| [Scoop](https:\u002F\u002Fscoop.sh\u002F) (Windows) | `scoop bucket add main && scoop install main\u002Fkubens main\u002Fkubectx` |\n| [winget](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fwindows\u002Fpackage-manager\u002F) (Windows) | `winget install --id ahmetb.kubectx && winget install --id ahmetb.kubens` |\n| [Krew](https:\u002F\u002Fgithub.com\u002Fkubernetes-sigs\u002Fkrew\u002F) (kubectl plugin) | `kubectl krew install ctx && kubectl krew install ns` |\n\nAlternatively, download binaries from the [**Releases page &rarr;**](https:\u002F\u002Fgithub.com\u002Fahmetb\u002Fkubectx\u002Freleases) and add them to somewhere in your `PATH`.\n\n\u003Cdetails>\n\u003Csummary>Shell completion scripts\u003C\u002Fsummary>\n\n#### zsh (with [antibody](https:\u002F\u002Fgetantibody.github.io))\n\nAdd this line to your [Plugins File](https:\u002F\u002Fgetantibody.github.io\u002Fusage\u002F) (e.g.\n`~\u002F.zsh_plugins.txt`):\n\n```\nahmetb\u002Fkubectx path:completion kind:fpath\n```\n\nDepending on your setup, you might or might not need to call `compinit` or\n`autoload -U compinit && compinit` in your `~\u002F.zshrc` after you load the Plugins\nfile. If you use [oh-my-zsh](https:\u002F\u002Fgithub.com\u002Fohmyzsh\u002Fohmyzsh), load the\ncompletions before you load `oh-my-zsh` because `oh-my-zsh` will call\n`compinit`.\n\n#### zsh (plain)\n\nThe completion scripts have to be in a path that belongs to `$fpath`. Either\nlink or copy them to an existing folder.\n\nExample with [`oh-my-zsh`](https:\u002F\u002Fgithub.com\u002Fohmyzsh\u002Fohmyzsh):\n\n```bash\nmkdir -p ~\u002F.oh-my-zsh\u002Fcustom\u002Fcompletions\nchmod -R 755 ~\u002F.oh-my-zsh\u002Fcustom\u002Fcompletions\nln -s \u002Fopt\u002Fkubectx\u002Fcompletion\u002F_kubectx.zsh ~\u002F.oh-my-zsh\u002Fcustom\u002Fcompletions\u002F_kubectx.zsh\nln -s \u002Fopt\u002Fkubectx\u002Fcompletion\u002F_kubens.zsh ~\u002F.oh-my-zsh\u002Fcustom\u002Fcompletions\u002F_kubens.zsh\necho \"fpath=($ZSH\u002Fcustom\u002Fcompletions $fpath)\" >> ~\u002F.zshrc\n```\n\nIf completion doesn't work, add `autoload -U compinit && compinit` to your\n`.zshrc` (similar to\n[`zsh-completions`](https:\u002F\u002Fgithub.com\u002Fzsh-users\u002Fzsh-completions\u002Fblob\u002Fmaster\u002FREADME.md#oh-my-zsh)).\n\nIf you are not using [`oh-my-zsh`](https:\u002F\u002Fgithub.com\u002Fohmyzsh\u002Fohmyzsh), you\ncould link to `\u002Fusr\u002Fshare\u002Fzsh\u002Ffunctions\u002FCompletion` (might require sudo),\ndepending on the `$fpath` of your zsh installation.\n\nIn case of errors, calling `compaudit` might help.\n\n#### bash\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fahmetb\u002Fkubectx.git ~\u002F.kubectx\nCOMPDIR=$(pkg-config --variable=completionsdir bash-completion)\nln -sf ~\u002F.kubectx\u002Fcompletion\u002Fkubens.bash $COMPDIR\u002Fkubens\nln -sf ~\u002F.kubectx\u002Fcompletion\u002Fkubectx.bash $COMPDIR\u002Fkubectx\ncat \u003C\u003C EOF >> ~\u002F.bashrc\n\n\n#kubectx and kubens\nexport PATH=~\u002F.kubectx:\\$PATH\nEOF\n```\n\n#### fish\n\n```fish\nmkdir -p ~\u002F.config\u002Ffish\u002Fcompletions\nln -s \u002Fopt\u002Fkubectx\u002Fcompletion\u002Fkubectx.fish ~\u002F.config\u002Ffish\u002Fcompletions\u002F\nln -s \u002Fopt\u002Fkubectx\u002Fcompletion\u002Fkubens.fish ~\u002F.config\u002Ffish\u002Fcompletions\u002F\n```\n\n\u003C\u002Fdetails>\n\n> [!NOTE]\n> Tip: Show context\u002Fnamespace in your shell prompt with [oh-my-posh](https:\u002F\u002Fohmyposh.dev\u002F) or\n> simply with [kube-ps1](https:\u002F\u002Fgithub.com\u002Fjonmosco\u002Fkube-ps1).\n\n-----\n\n### Interactive mode\n\nIf you want `kubectx` and `kubens` commands to present you an interactive menu\nwith fuzzy searching, you just need to [install\n`fzf`](https:\u002F\u002Fgithub.com\u002Fjunegunn\u002Ffzf) in your `$PATH`.\n\n![kubectx interactive search with fzf](img\u002Fkubectx-interactive.gif)\n\nCaveats:\n- If you have `fzf` installed, but want to opt out of using this feature, set the\n  environment variable `KUBECTX_IGNORE_FZF=1`.\n- If you want to keep `fzf` interactive mode but need the default behavior of the\n  command, you can do it by piping the output to another command (e.g. `kubectx |\n  cat `).\n\n-----\n\n### Customizing colors\n\nIf you like to customize the colors indicating the current namespace or context,\nset the environment variables `KUBECTX_CURRENT_FGCOLOR` and\n`KUBECTX_CURRENT_BGCOLOR` (refer color codes\n[here](https:\u002F\u002Flinux.101hacks.com\u002Fps1-examples\u002Fprompt-color-using-tput\u002F)):\n\n```sh\nexport KUBECTX_CURRENT_FGCOLOR=$(tput setaf 6) # blue text\nexport KUBECTX_CURRENT_BGCOLOR=$(tput setab 7) # white background\n```\n\nColors in the output can be disabled by setting the\n[`NO_COLOR`](https:\u002F\u002Fno-color.org\u002F) environment variable.\n\n-----\n\nIf you liked `kubectx`, you may like my\n[`kubectl-aliases`](https:\u002F\u002Fgithub.com\u002Fahmetb\u002Fkubectl-aliases) project, too. I\nrecommend pairing kubectx and kubens with [fzf](#interactive-mode) and\n[kube-ps1](https:\u002F\u002Fgithub.com\u002Fjonmosco\u002Fkube-ps1).\n\n#### Stargazers over time\n\n[![Stargazers over time](https:\u002F\u002Fstarchart.cc\u002Fahmetb\u002Fkubectx.svg)](https:\u002F\u002Fstarchart.cc\u002Fahmetb\u002Fkubectx)\n![Google Analytics](https:\u002F\u002Fga-beacon.appspot.com\u002FUA-2609286-17\u002Fkubectx\u002FREADME?pixel) \u003C!-- TODO broken since Aug 2021 as igrigorik left Google -->\n","kubectx 是一个用于快速切换 kubectl 上下文（集群）和命名空间的工具。它提供了两个核心命令：`kubectx` 用于在不同的 Kubernetes 集群间快速切换，并支持启动只读或隔离的 shell 环境；`kubens` 则简化了命名空间之间的切换操作。这两个工具都支持模糊搜索和交互式选择，极大提高了多集群或多命名空间管理时的工作效率。适用于需要频繁切换 Kubernetes 集群或命名空间进行开发、测试、运维等工作的场景。项目使用 Go 语言编写，遵循 Apache License 2.0 开源协议，可通过多种包管理器轻松安装。",2,"2026-06-11 03:00:39","top_language"]