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