高效终端命令行工具

目录
导语
工欲善其事,必先利其器。

作为技术人员,一个高效的工作环境尤为重要。下面分享下我的终端命令行下的环境和工具配置。

参考:https://ohmyz.sh/

1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
1
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

最后记得将它们加到.zshrc里。

可参考https://github.com/whitefirer/workspace/blob/main/.zshrc进行配置:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# .zshrc
function right_prompt() {
  local color="blue"

  if [[ "$ZSH_KUBECTL_NAMESPACE" =~ "system" ]]; then
    color="yellow"
  fi

  if [[ "$ZSH_KUBECTL_CONTEXT" =~ "desktop" || "$ZSH_KUBECTL_CONTEXT" =~ "dev" ]]; then
    color="green"
  fi

  if [[ "$ZSH_KUBECTL_CONTEXT" =~ "prod" ]]; then
    color="red"
  fi

  echo "%{$terminfo[bold]$fg[$color]%}\u2638($ZSH_KUBECTL_PROMPT)%{$reset_color%}"
}
RPROMPT='$(right_prompt)'

成功后会显示如下:

# Let's see how the zsh-kubectl-prompt works.                                                                      ~ ctx                                                                            ☸(cni-test/wesing-service)     Switched to context "cni-prod".                                                                                    ~ ctx                                                                             ☸(cni-prod/cluster-check)     Switched to context "cni-dev".                                                                                     ~ ctx                                                                                       ☸(cni-dev/base)     Switched to context "docker-desktop".                                                                              ~ ctx                                                                             ☸(docker-desktop/default)     Switched to context "mtke-test".                                                                                   ~ ns                                                                                      ☸(mtke-test/base)     Context "mtke-test" modified.                                                                                      Active namespace is "istio-system".                                                                                ~ ns                                                                              ☸(mtke-test/istio-system)     Context "mtke-test" modified.                                                                                      Active namespace is "kube-system".                                                                                 ~ ns                                                                               ☸(mtke-test/kube-system)     Context "mtke-test" modified.                                                                                      Active namespace is "base".                                                                                        ~ k get vs helloworld -oyaml                                                              ☸(mtke-test/base)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
00:00-00:57
"zsh-kubectl-prompt"

其中cni-test为自己在kubeconfig中给context取的名字,可自行修改。 里面的ctxns均为krew插件。

其它可参考:https://kubernetes.io/docs/tasks/tools/#install-kubectl

更多相关备忘:https://kubernetes.io/zh/docs/reference/kubectl/cheatsheet/

参考:https://krew.sigs.k8s.io/

可以参考https://github.com/hidetatz/kubecolor readme里的做法,alias成k或者kubectl。

GitHub:https://github.com/tmux/tmux

参考:https://www.ruanyifeng.com/blog/2019/10/tmux.html

参考:https://github.com/sharkdp/bat/blob/master/doc/README-zh.md

参考:https://github.com/junegunn/fzf#preview-window

右侧的预览是结合了前面的bat命令。

参考:https://github.com/ogham/exa

1
brew install htop
1
brew install jq
1
brew install fx

https://github.com/antonmedv/fx

当然有使用kubecolor的话,kubectl也用不上yh,但是其它命令场景还是可以用的。

1
brew install yh
来发评论吧~
Powered By Valine
v1.5.0