Box

Allgemein

Profil

Zsh for kubernetes okd » Historie » Zyklus 5

Peter Pfläging, 24.06.2021 16:25

1 3 Peter Pfläging
# Zsh for kubernetes okd
2 1 Peter Pfläging
3 2 Peter Pfläging
It's fine to see the actual kube oder oc env, the git status of the actual dir in the prompt:
4 3 Peter Pfläging
5 5 Peter Pfläging
![](zsh-prompt.png)
6 2 Peter Pfläging
7 5 Peter Pfläging
After the installation you can turn the prompt On or Off with `kubeon` or `kubeoff`
8 4 Peter Pfläging
9 2 Peter Pfläging
*   install `zsh`
10
    *   MacOS (it's there and OK)
11
    *   CentOS, RHEL, fedora: `sudo install -y zsh`
12
    *   Debian, Ubuntu, raspbian: `sudo apt install -y zsh`
13
    *   Windows? =Y You're kidding, use WSL2
14
*   change your login shell like: `usermod -s /bin/zsh $USER`
15
*   install ohmyz.sh: `sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"`
16
*   create a `~/.zshrc` with the following content:
17
    
18
    ~~~
19
    ZSH_DISABLE_COMPFIX=true
20
    export ZSH="$HOME/.oh-my-zsh"
21
    ZSH_THEME="agnoster"
22
    export KUBE_PS1_BINARY=oc
23
    export KUBE_PS1_SYMBOL_USE_IMG=true
24
    export KUBE_PS1_BG_COLOR=black
25
    export KUBE_PS1_SYMBOL_COLOR=red
26
    export KUBE_PS1_CTX_COLOR=blue
27
    function get_cluster_short() {
28
    echo "$1" | sed 's&.*/api-\([^-]*\)-.*:6443/\(.*\)&\1/\2&'
29
    }
30
    KUBE_PS1_CLUSTER_FUNCTION=get_cluster_short
31
    if [[ -n $TERM_PROGRAM ]]; then
32
    #we're on a macos
33
    plugins=(ansible bundler django docker docker-compose git iterm2 kubectl oc python ruby tmux rails themes kube-ps1 chezmoi)
34
    else
35
    # we're everywhere else
36
    plugins=(ansible bundler git kubectl oc python ruby tmux themes kube-ps1)
37
    fi
38
    source $ZSH/oh-my-zsh.sh
39
    if [[ -n $SSH_CONNECTION ]]; then
40 1 Peter Pfläging
    export EDITOR='emacs -nw'
41 2 Peter Pfläging
    else
42
    export EDITOR='emacs -nw'
43
    fi
44
    if [[ -d /Library ]]; then
45
    #we're on a macos
46
    export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/
47
    else
48
    # we're everywhere else
49
    export EDITOR=vi
50
    fi
51
    if command -v emacs &> /dev/null
52
    then
53
    export EDITOR='emacs -nw'
54 1 Peter Pfläging
    alias emacs='emacs -nw'
55 2 Peter Pfläging
    else
56 1 Peter Pfläging
    export EDITOR='vi'
57 2 Peter Pfläging
    fi
58
    export PATH=$PATH:$HOME/go/bin
59
    test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
60
    test -e "${HOME}/.zshrc_local" && source "${HOME}/.zshrc_local"
61
    export PROMPT='$(kube_ps1)'$PROMPT
62
    ~~~
63
    
64
*   for local mods, put them in `$HOME/.zshrc_local`
65
    
66
*   install `kubectl` and `oc`