Skip to content

Commit 4a7886d

Browse files
committed
Add kn command + Minor improvements
1 parent 85ed668 commit 4a7886d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.zshrc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ alias ssht="ssh_multi"
106106
alias flat="cat_flat"
107107
alias ll="ls_ext"
108108
alias l="ls_ext"
109+
alias kn="k8s_namespace"
109110

110111
# Traps
111112
alias git="git_trap"
@@ -414,6 +415,11 @@ function go_clone() {
414415
}
415416

416417
function create_backup() {
418+
if [[ $# -eq 0 ]] ; then
419+
echo "Usage: bkp {file}"
420+
return 0
421+
fi
422+
417423
if ! cp -rp "$1" "$1.bak" ; then
418424
return 1
419425
fi
@@ -453,13 +459,24 @@ function ssh_multi() {
453459

454460
function cat_flat() {
455461
if [[ $# -lt 2 ]] ; then
456-
echo "Usage: flat file"
462+
echo "Usage: flat {file}"
457463
return 0
458464
fi
459465

460466
cat $1 | tr '\n' ' ' ; echo ""
461467
}
462468

469+
function k8s_namespace() {
470+
if [[ $# -eq 0 ]] ; then
471+
kubectl get ns -o 'jsonpath={.items[*].metadata.name}' | tr ' ' '\n' | grep -vE '(kube-.*|yandex-.*)'
472+
return $?
473+
fi
474+
475+
kubectl config set-context --current --namespace="$1"
476+
477+
return $?
478+
}
479+
463480
function tmux_win_to_path() {
464481
if [[ -z "$TMUX" ]] ; then
465482
return 1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bash <(curl -fsSL https://andy.one/dotfiles/install.sh)
2626
| `dr …` | Docker `run` shortcut |
2727
| `de …` | Docker `exec` shortcut |
2828
| `k …` | `kubectl` shortcut |
29+
| `kn {namespace}` | Set k8s namespace |
2930
| `lll …` | List files and directories using [`eza`](https://github.com/eza-community/eza) |
3031
| `llg …` | List files and directories using [`eza`](https://github.com/eza-community/eza) with `git` status |
3132
| `hf …` | `grep` over zsh history |

0 commit comments

Comments
 (0)