Box

Allgemein

Profil

Zsh for kubernetes okd » Historie » Revision 2

Revision 1 (Peter Pfläging, 24.06.2021 14:51) → Revision 2/6 (Peter Pfläging, 24.06.2021 14:59)

#  
 ![](zsh-prompt.png) 
 Zsh for kubernetes    okd 

 It's fine to see the actual kube oder oc env, the git status of the actual dir in the prompt: 

 *     - install `zsh` 
     *     
   - MacOS (it's there and OK) 
     *     
   - CentOS, RHEL, fedora: `sudo install -y zsh` 
     *     
   - Debian, Ubuntu, raspbian: `sudo apt install -y zsh` 
     *     
   - Windows? =Y You're kidding, use WSL2 
 *     - change your login shell like: `usermod -s /bin/zsh $USER` 
 *      
 - install ohmyz.sh: `sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` 
 *     - create a `~/.zshrc` with the following content: 
    
     ~~~ 
     
    ```shell 
 ZSH_DISABLE_COMPFIX=true 
     
 export ZSH="$HOME/.oh-my-zsh" 
     
 ZSH_THEME="agnoster" 
     
 export KUBE_PS1_BINARY=oc 
     
 export KUBE_PS1_SYMBOL_USE_IMG=true 
     
 export KUBE_PS1_BG_COLOR=black 
     
 export KUBE_PS1_SYMBOL_COLOR=red 
     
 export KUBE_PS1_CTX_COLOR=blue 
     
 function get_cluster_short() { 
     
   echo "$1" | sed 's&.*/api-\([^-]*\)-.*:6443/\(.*\)&\1/\2&' 
     
 } 
     
 KUBE_PS1_CLUSTER_FUNCTION=get_cluster_short 
     
 if [[ -n $TERM_PROGRAM ]]; then 
     
	 #we're on a macos 
     
	 plugins=(ansible bundler django docker docker-compose git iterm2 kubectl oc python ruby tmux rails themes kube-ps1 chezmoi) 
     
 else 
     
	 # we're everywhere else 
     
	 plugins=(ansible bundler git kubectl oc python ruby tmux themes kube-ps1) 
     
 fi 
     
 source $ZSH/oh-my-zsh.sh 
     
 if [[ -n $SSH_CONNECTION ]]; then 
     
    export EDITOR='emacs -nw' 
     
 else 
     
    export EDITOR='emacs -nw' 
     
 fi 
     
 if [[ -d /Library ]]; then 
     
	 #we're on a macos 
     
	 export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/ 
     
 else 
     
	 # we're everywhere else 
     
	 export EDITOR=vi 
     
 fi 
     
 if command -v emacs &> /dev/null 
     
 then 
     export EDITOR='emacs -nw' 
     alias emacs='emacs -nw' 
     
 else 
     export EDITOR='vi' 
     
 fi 
     
 export PATH=$PATH:$HOME/go/bin 
     
 test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh" 
     
 test -e "${HOME}/.zshrc_local" && source "${HOME}/.zshrc_local" 
     
 export PROMPT='$(kube_ps1)'$PROMPT 
     ~~~ 
    
 *     for local mods, put them in `$HOME/.zshrc_local` 
    
 *     install `kubectl` and `oc` 
    ```