Last active
November 20, 2022 11:17
-
-
Save ahmedig/f6c7a7b5076bf3a3d678e34a711cb7ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH="/Users/ahmedelsayed/.oh-my-zsh" | |
# Set name of the theme to load --- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | |
#ZSH_THEME="robbyrussell" | |
ZSH_THEME="powerlevel9k/powerlevel9k" | |
# Set list of themes to pick from when loading at random | |
# Setting this variable when ZSH_THEME=random will cause zsh to load | |
# a theme from this variable instead of looking in $ZSH/themes/ | |
# If set to an empty array, this variable will have no effect. | |
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
# Uncomment the following line to use case-sensitive completion. | |
# CASE_SENSITIVE="true" | |
# Uncomment the following line to use hyphen-insensitive completion. | |
# Case-sensitive completion must be off. _ and - will be interchangeable. | |
# HYPHEN_INSENSITIVE="true" | |
# Uncomment the following line to disable bi-weekly auto-update checks. | |
# DISABLE_AUTO_UPDATE="true" | |
# Uncomment the following line to automatically update without prompting. | |
# DISABLE_UPDATE_PROMPT="true" | |
# Uncomment the following line to change how often to auto-update (in days). | |
# export UPDATE_ZSH_DAYS=13 | |
# Uncomment the following line if pasting URLs and other text is messed up. | |
# DISABLE_MAGIC_FUNCTIONS=true | |
# Uncomment the following line to disable colors in ls. | |
# DISABLE_LS_COLORS="true" | |
# Uncomment the following line to disable auto-setting terminal title. | |
# DISABLE_AUTO_TITLE="true" | |
# Uncomment the following line to enable command auto-correction. | |
# ENABLE_CORRECTION="true" | |
# Uncomment the following line to display red dots whilst waiting for completion. | |
# COMPLETION_WAITING_DOTS="true" | |
# Uncomment the following line if you want to disable marking untracked files | |
# under VCS as dirty. This makes repository status check for large repositories | |
# much, much faster. | |
# DISABLE_UNTRACKED_FILES_DIRTY="true" | |
# Uncomment the following line if you want to change the command execution time | |
# stamp shown in the history command output. | |
# You can set one of the optional three formats: | |
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
# or set a custom format using the strftime function format specifications, | |
# see 'man strftime' for details. | |
# HIST_STAMPS="mm/dd/yyyy" | |
# Would you like to use another custom folder than $ZSH/custom? | |
# ZSH_CUSTOM=/path/to/new-custom-folder | |
# Which plugins would you like to load? | |
# Standard plugins can be found in $ZSH/plugins/ | |
# Custom plugins may be added to $ZSH_CUSTOM/plugins/ | |
# Example format: plugins=(rails git textmate ruby lighthouse) | |
# Add wisely, as too many plugins slow down shell startup. | |
plugins=(git git-flow brew history node npm kubectl) | |
source $ZSH/oh-my-zsh.sh | |
# User configuration | |
# export MANPATH="/usr/local/man:$MANPATH" | |
# You may need to manually set your language environment | |
# export LANG=en_US.UTF-8 | |
# Preferred editor for local and remote sessions | |
# if [[ -n $SSH_CONNECTION ]]; then | |
# export EDITOR='vim' | |
# else | |
# export EDITOR='mvim' | |
# fi | |
# Compilation flags | |
# export ARCHFLAGS="-arch x86_64" | |
# Set personal aliases, overriding those provided by oh-my-zsh libs, | |
# plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
# users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
# For a full list of active aliases, run `alias`. | |
# | |
# Example aliases | |
# alias zshconfig="mate ~/.zshrc" | |
# alias ohmyzsh="mate ~/.oh-my-zsh" | |
function code { | |
if [[ $# = 0 ]] | |
then | |
open -a "Visual Studio Code" | |
else | |
local argPath="$1" | |
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}" | |
open -a "Visual Studio Code" "$argPath" | |
fi | |
} | |
bindkey "^[^[[C" forward-word | |
bindkey "^[^[[D" backward-word | |
####################################################### APPEND THE BELOW PART! | |
POWERLEVEL9K_MODE='nerdfont-complete' | |
# Please only use this battery segment if you have material icons in your nerd font (or font) | |
# Otherwise, use the font awesome one in "User Segments" | |
prompt_zsh_battery_level() { | |
local percentage1=`pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p'` | |
local percentage=`echo "${percentage1//\%}"` | |
local color='%F{red}' | |
local symbol="\uf00d" | |
pmset -g ps | grep "discharging" > /dev/null | |
if [ $? -eq 0 ]; then | |
local charging="false"; | |
else | |
local charging="true"; | |
fi | |
if [ $percentage -le 20 ] | |
then symbol='\uf579' ; color='%F{red}' ; | |
#10% | |
elif [ $percentage -gt 19 ] && [ $percentage -le 30 ] | |
then symbol="\uf57a" ; color='%F{red}' ; | |
#20% | |
elif [ $percentage -gt 29 ] && [ $percentage -le 40 ] | |
then symbol="\uf57b" ; color='%F{yellow}' ; | |
#35% | |
elif [ $percentage -gt 39 ] && [ $percentage -le 50 ] | |
then symbol="\uf57c" ; color='%F{yellow}' ; | |
#45% | |
elif [ $percentage -gt 49 ] && [ $percentage -le 60 ] | |
then symbol="\uf57d" ; color='%F{blue}' ; | |
#55% | |
elif [ $percentage -gt 59 ] && [ $percentage -le 70 ] | |
then symbol="\uf57e" ; color='%F{blue}' ; | |
#65% | |
elif [ $percentage -gt 69 ] && [ $percentage -le 80 ] | |
then symbol="\uf57f" ; color='%F{blue}' ; | |
#75% | |
elif [ $percentage -gt 79 ] && [ $percentage -le 90 ] | |
then symbol="\uf580" ; color='%F{blue}' ; | |
#85% | |
elif [ $percentage -gt 89 ] && [ $percentage -le 99 ] | |
then symbol="\uf581" ; color='%F{blue}' ; | |
#85% | |
elif [ $percentage -gt 98 ] | |
then symbol="\uf578" ; color='%F{green}' ; | |
#100% | |
fi | |
if [ $charging = "true" ]; | |
then color='%F{green}'; if [ $percentage -gt 98 ]; then symbol='\uf584'; fi | |
fi | |
echo -n "%{$color%}$symbol" ; | |
} | |
zsh_internet_signal(){ | |
local color | |
local symbol="\uf7ba" | |
if ifconfig en0 | grep inactive &> /dev/null; then | |
color="%F{red}" | |
else | |
color="%F{blue}" | |
fi | |
echo -n "%{$color%}$symbol " | |
} | |
POWERLEVEL9K_PROMPT_ON_NEWLINE=false | |
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true | |
POWERLEVEL9K_RPROMPT_ON_NEWLINE=false | |
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 | |
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_beginning" | |
POWERLEVEL9K_RVM_BACKGROUND="black" | |
POWERLEVEL9K_RVM_FOREGROUND="249" | |
POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="red" | |
POWERLEVEL9K_TIME_BACKGROUND="black" | |
POWERLEVEL9K_TIME_FOREGROUND="249" | |
POWERLEVEL9K_TIME_FORMAT="\UF43A %D{%I:%M \UF133 %d.%m.%y}" | |
POWERLEVEL9K_RVM_BACKGROUND="black" | |
POWERLEVEL9K_RVM_FOREGROUND="249" | |
POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="red" | |
POWERLEVEL9K_STATUS_VERBOSE=false | |
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='black' | |
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='green' | |
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='black' | |
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow' | |
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='white' | |
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='black' | |
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='black' | |
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='blue' | |
POWERLEVEL9K_FOLDER_ICON='' | |
POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE=true | |
POWERLEVEL9K_STATUS_VERBOSE=false | |
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 | |
POWERLEVEL9K_VCS_UNTRACKED_ICON='\u25CF' | |
POWERLEVEL9K_VCS_UNSTAGED_ICON='\u00b1' | |
POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='\u2193' | |
POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='\u2191' | |
POWERLEVEL9K_VCS_COMMIT_ICON="\uf417" | |
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%f" | |
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%f " | |
POWERLEVEL9K_CUSTOM_BATTERY_STATUS="prompt_zsh_battery_level" | |
#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context os_icon custom_internet_signal custom_battery_status_joined ssh root_indicator dir dir_writable vcs) | |
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_internet_signal ssh root_indicator dir dir_writable vcs) | |
#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time kubecontext status time) | |
#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time kubecontext status time) | |
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time kubecontext) | |
HIST_STAMPS="dd/mm/yyyy" | |
DISABLE_UPDATE_PROMPT=true | |
###################### KUBECTL CONFIG ####################### | |
if (( $+commands[kubectl] )); then | |
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion" | |
if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then | |
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE | |
fi | |
[[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE | |
unset __KUBECTL_COMPLETION_FILE | |
fi | |
# This command is used a LOT both below and in daily life | |
alias k=kubectl | |
alias tf=terraform | |
# Execute a kubectl command against all namespaces | |
alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f' | |
# Apply a YML file | |
alias kaf='kubectl apply -f' | |
# Drop into an interactive terminal on a container | |
alias keti='kubectl exec -ti' | |
# Manage configuration quickly to switch contexts between local, dev ad staging. | |
alias kcuc='kubectl config use-context' | |
alias kcsc='kubectl config set-context' | |
alias kcdc='kubectl config delete-context' | |
alias kccc='kubectl config current-context' | |
# List all contexts | |
alias kcgc='kubectl config get-contexts' | |
# General aliases | |
alias kdel='kubectl delete' | |
alias kdelf='kubectl delete -f' | |
# Pod management. | |
alias kgp='kubectl get pods' | |
alias kgpw='kgp --watch' | |
alias kgpwide='kgp -o wide' | |
alias kep='kubectl edit pods' | |
alias kdp='kubectl describe pods' | |
alias kdelp='kubectl delete pods' | |
# get pod by label: kgpl "app=myapp" -n myns | |
alias kgpl='kgp -l' | |
# Service management. | |
alias kgs='kubectl get svc' | |
alias kgsw='kgs --watch' | |
alias kgswide='kgs -o wide' | |
alias kes='kubectl edit svc' | |
alias kds='kubectl describe svc' | |
alias kdels='kubectl delete svc' | |
# Ingress management | |
alias kgi='kubectl get ingress' | |
alias kei='kubectl edit ingress' | |
alias kdi='kubectl describe ingress' | |
alias kdeli='kubectl delete ingress' | |
# Namespace management | |
alias kgns='kubectl get namespaces' | |
alias kens='kubectl edit namespace' | |
alias kdns='kubectl describe namespace' | |
alias kdelns='kubectl delete namespace' | |
alias kcn='kubectl config set-context $(kubectl config current-context) --namespace' | |
# ConfigMap management | |
alias kgcm='kubectl get configmaps' | |
alias kecm='kubectl edit configmap' | |
alias kdcm='kubectl describe configmap' | |
alias kdelcm='kubectl delete configmap' | |
# Secret management | |
alias kgsec='kubectl get secret' | |
alias kdsec='kubectl describe secret' | |
alias kdelsec='kubectl delete secret' | |
# Deployment management. | |
alias kgd='kubectl get deployment' | |
alias kgdw='kgd --watch' | |
alias kgdwide='kgd -o wide' | |
alias ked='kubectl edit deployment' | |
alias kdd='kubectl describe deployment' | |
alias kdeld='kubectl delete deployment' | |
alias ksd='kubectl scale deployment' | |
alias krsd='kubectl rollout status deployment' | |
kres(){ | |
kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S) | |
} | |
# Rollout management. | |
alias kgrs='kubectl get rs' | |
alias krh='kubectl rollout history' | |
alias kru='kubectl rollout undo' | |
# Statefulset management. | |
alias kgss='kubectl get statefulset' | |
alias kgssw='kgss --watch' | |
alias kgsswide='kgss -o wide' | |
alias kess='kubectl edit statefulset' | |
alias kdss='kubectl describe statefulset' | |
alias kdelss='kubectl delete statefulset' | |
alias ksss='kubectl scale statefulset' | |
alias krsss='kubectl rollout status statefulset' | |
# Port forwarding | |
alias kpf="kubectl port-forward" | |
# Tools for accessing all information | |
alias kga='kubectl get all' | |
alias kgaa='kubectl get all --all-namespaces' | |
# Logs | |
alias kl='kubectl logs' | |
alias klf='kubectl logs -f' | |
# File copy | |
alias kcp='kubectl cp' | |
# Node Management | |
alias kgno='kubectl get nodes' | |
alias keno='kubectl edit node' | |
alias kdno='kubectl describe node' | |
alias kdelno='kubectl delete node' | |
alias knodes='k get nodes -o custom-columns=NAME:.metadata.name,PRIVATEIP:.status.addresses[1].address' | |
# PVC management. | |
alias kgpvc='kubectl get pvc' | |
alias kgpvcw='kgpvc --watch' | |
alias kepvc='kubectl edit pvc' | |
alias kdpvc='kubectl describe pvc' | |
alias kdelpvc='kubectl delete pvc' | |
# kubernetes ssh | |
alias ksshnp='ssh -i ~/.ssh/id_rsa_aks_nonprod -l azureuser' | |
alias ksshp='ssh -i ~/.ssh/id_rsa_aks_prod -l azureuser' | |
source <(kubectl completion zsh) | |
################ END KUBECTL CONFIG ############## | |
export PATH=$GOPATH:$GOBIN:$PATH | |
source $ZSH/oh-my-zsh.sh | |
autoload -U +X bashcompinit && bashcompinit | |
complete -o nospace -C /usr/local/bin/terraform terraform | |
source /usr/local/etc/bash_completion.d/az | |
oh my zsh settings from my kasna laptop:
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/ahmedelsaeidy/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(history)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor root line)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')
plugins=(
brew
gcloud
git
gradle
ng
npm
yarn
zsh-autosuggestions
osx
sdkman
kubectl
)
alias x="exit"
alias sz="source ~/.zshrc"
alias hc="history -c"
alias kasna="cd /Users/ahmedelsaeidy/Work/Kasna"
#Include Z
if command -v brew >/dev/null 2>&1; then
# Load rupa's z if installed
[ -f $(brew --prefix)/etc/profile.d/z.sh ] && source $(brew --prefix)/etc/profile.d/z.sh
fi
fpath=($fpath ~/.zsh/completion)
###################
# start-cmdline
###################
start-cmdline() {
touch ${HOME}/.bash_history_cmdline
docker pull cmdsolutions/cmdline:bleeding
docker run \
-v "${HOME}/.ssh:/root/.ssh" \
-v "${HOME}/.aws:/root/.aws" \
-v "${HOME}/cmd_source:/ansible" \
-v "${HOME}/.gitconfig:/root/.gitconfig" \
-v "${HOME}/usr/local/bin/" \
-it cmdsolutions/cmdline:bleeding /bin/bash
}
okta-shell() {
docker run --rm -it \
-v "${HOME}/.aws:/root/.aws" \
--entrypoint=oktashell \
cmdlabs/okta-utils:latest \
-u ahmed.elsayed \
-a runcmd \
-d 28800 \
-m push \
-p idp-readonly
#-o arn:aws:iam::198684731458:role/runcmd-role-idp-clientreadonly \
}
okta-runcmd() {
OktaShell -u ahmed.elsayed -d 28800 -a runcmd -m push
}
breakglass() {
docker run --rm -it -v ~/.aws:/root/.aws -e AWS_DEFAULT_REGION=ap-southeast-2 -e AWS_PROFILE=idp-readonly cmdsolutions/cmdline:bleeding /root/bin/BreakGlass -u ahmed.elsayed@kasna.com.au $@
}
########################
# End-cmdline
########################
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to automatically update without prompting.
# DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS=true
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
# plugins=(git)
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
export GOPATH=$HOME/go
export GOBIN=$HOME/go/bin
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
source $ZSH/oh-my-zsh.sh
####################### POWERLINE CONFIG!!! ###################
POWERLEVEL9K_MODE='nerdfont-complete'
# Please only use this battery segment if you have material icons in your nerd font (or font)
# Otherwise, use the font awesome one in "User Segments"
prompt_zsh_battery_level() {
local percentage1=`pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p'`
local percentage=`echo "${percentage1//\%}"`
local color='%F{red}'
local symbol="\uf00d"
pmset -g ps | grep "discharging" > /dev/null
if [ $? -eq 0 ]; then
local charging="false";
else
local charging="true";
fi
if [ $percentage -le 20 ]
then symbol='\uf579' ; color='%F{red}' ;
#10%
elif [ $percentage -gt 19 ] && [ $percentage -le 30 ]
then symbol="\uf57a" ; color='%F{red}' ;
#20%
elif [ $percentage -gt 29 ] && [ $percentage -le 40 ]
then symbol="\uf57b" ; color='%F{yellow}' ;
#35%
elif [ $percentage -gt 39 ] && [ $percentage -le 50 ]
then symbol="\uf57c" ; color='%F{yellow}' ;
#45%
elif [ $percentage -gt 49 ] && [ $percentage -le 60 ]
then symbol="\uf57d" ; color='%F{blue}' ;
#55%
elif [ $percentage -gt 59 ] && [ $percentage -le 70 ]
then symbol="\uf57e" ; color='%F{blue}' ;
#65%
elif [ $percentage -gt 69 ] && [ $percentage -le 80 ]
then symbol="\uf57f" ; color='%F{blue}' ;
#75%
elif [ $percentage -gt 79 ] && [ $percentage -le 90 ]
then symbol="\uf580" ; color='%F{blue}' ;
#85%
elif [ $percentage -gt 89 ] && [ $percentage -le 99 ]
then symbol="\uf581" ; color='%F{blue}' ;
#85%
elif [ $percentage -gt 98 ]
then symbol="\uf578" ; color='%F{green}' ;
#100%
fi
if [ $charging = "true" ];
then color='%F{green}'; if [ $percentage -gt 98 ]; then symbol='\uf584'; fi
fi
echo -n "%{$color%}$symbol" ;
}
zsh_internet_signal(){
local color
local symbol="\uf7ba"
if ifconfig en0 | grep inactive &> /dev/null; then
color="%F{red}"
else
color="%F{blue}"
fi
echo -n "%{$color%}$symbol "
}
POWERLEVEL9K_PROMPT_ON_NEWLINE=false
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=false
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_beginning"
POWERLEVEL9K_RVM_BACKGROUND="black"
POWERLEVEL9K_RVM_FOREGROUND="249"
POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="red"
POWERLEVEL9K_TIME_BACKGROUND="black"
POWERLEVEL9K_TIME_FOREGROUND="249"
POWERLEVEL9K_TIME_FORMAT="\UF43A %D{%I:%M \UF133 %d.%m.%y}"
POWERLEVEL9K_RVM_BACKGROUND="black"
POWERLEVEL9K_RVM_FOREGROUND="249"
POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="red"
POWERLEVEL9K_STATUS_VERBOSE=false
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='black'
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='green'
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='black'
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='white'
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='black'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='black'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='blue'
POWERLEVEL9K_FOLDER_ICON=''
POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE=true
POWERLEVEL9K_STATUS_VERBOSE=false
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
POWERLEVEL9K_VCS_UNTRACKED_ICON='\u25CF'
POWERLEVEL9K_VCS_UNSTAGED_ICON='\u00b1'
POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='\u2193'
POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='\u2191'
POWERLEVEL9K_VCS_COMMIT_ICON="\uf417"
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}\u256D\u2500%f"
POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}\u2570\uf460%f "
POWERLEVEL9K_CUSTOM_BATTERY_STATUS="prompt_zsh_battery_level"
#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context os_icon custom_internet_signal custom_battery_status_joined ssh root_indicator dir dir_writable vcs)
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_internet_signal ssh root_indicator dir dir_writable vcs)
#POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time kubecontext status time)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time kubecontext status time)
HIST_STAMPS="dd/mm/yyyy"
DISABLE_UPDATE_PROMPT=true
####################### END POWERLINE CONFIG #######################
###################### KUBECTL CONFIG #######################
if (( $+commands[kubectl] )); then
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
fi
[[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE
unset __KUBECTL_COMPLETION_FILE
fi
# This command is used a LOT both below and in daily life
alias k=kubectl
# Execute a kubectl command against all namespaces
alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f'
# Apply a YML file
alias kaf='kubectl apply -f'
# Drop into an interactive terminal on a container
alias keti='kubectl exec -ti'
# Manage configuration quickly to switch contexts between local, dev ad staging.
alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
alias kccc='kubectl config current-context'
# List all contexts
alias kcgc='kubectl config get-contexts'
# General aliases
alias kdel='kubectl delete'
alias kdelf='kubectl delete -f'
# Pod management.
alias kgp='kubectl get pods'
alias kgpw='kgp --watch'
alias kgpwide='kgp -o wide'
alias kep='kubectl edit pods'
alias kdp='kubectl describe pods'
alias kdelp='kubectl delete pods'
# get pod by label: kgpl "app=myapp" -n myns
alias kgpl='kgp -l'
# Service management.
alias kgs='kubectl get svc'
alias kgsw='kgs --watch'
alias kgswide='kgs -o wide'
alias kes='kubectl edit svc'
alias kds='kubectl describe svc'
alias kdels='kubectl delete svc'
# Ingress management
alias kgi='kubectl get ingress'
alias kei='kubectl edit ingress'
alias kdi='kubectl describe ingress'
alias kdeli='kubectl delete ingress'
# Namespace management
alias kgns='kubectl get namespaces'
alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace'
alias kcn='kubectl config set-context $(kubectl config current-context) --namespace'
# ConfigMap management
alias kgcm='kubectl get configmaps'
alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap'
# Secret management
alias kgsec='kubectl get secret'
alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret'
# Deployment management.
alias kgd='kubectl get deployment'
alias kgdw='kgd --watch'
alias kgdwide='kgd -o wide'
alias ked='kubectl edit deployment'
alias kdd='kubectl describe deployment'
alias kdeld='kubectl delete deployment'
alias ksd='kubectl scale deployment'
alias krsd='kubectl rollout status deployment'
kres(){
kubectl set env $@ REFRESHED_AT=$(date +%Y%m%d%H%M%S)
}
# Rollout management.
alias kgrs='kubectl get rs'
alias krh='kubectl rollout history'
alias kru='kubectl rollout undo'
# Statefulset management.
alias kgss='kubectl get statefulset'
alias kgssw='kgss --watch'
alias kgsswide='kgss -o wide'
alias kess='kubectl edit statefulset'
alias kdss='kubectl describe statefulset'
alias kdelss='kubectl delete statefulset'
alias ksss='kubectl scale statefulset'
alias krsss='kubectl rollout status statefulset'
# Port forwarding
alias kpf="kubectl port-forward"
# Tools for accessing all information
alias kga='kubectl get all'
alias kgaa='kubectl get all --all-namespaces'
# Logs
alias kl='kubectl logs'
alias klf='kubectl logs -f'
# File copy
alias kcp='kubectl cp'
# Node Management
alias kgno='kubectl get nodes'
alias keno='kubectl edit node'
alias kdno='kubectl describe node'
alias kdelno='kubectl delete node'
# PVC management.
alias kgpvc='kubectl get pvc'
alias kgpvcw='kgpvc --watch'
alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc'
alias kdelpvc='kubectl delete pvc'
source <(kubectl completion zsh)
################ END KUBECTL CONFIG ##############
export PATH=$GOPATH:$GOBIN:$PATH
source $ZSH/oh-my-zsh.sh
iterm2 config
Font: Heck nerd font, Regular
VSCode:
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "MesloLGMDZ Nerd Font",
"terminal.integrated.shell.osx": "/bin/zsh",
Apps:
Clipy
Reverse scrolling
Lastpass
Spectacle
brew tap homebrew/cask-fonts
brew cask install font-hack-nerd-font
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.fontFamily": "'Source Code Pro for Powerline', 'Hack Nerd Font', 'MesloLGS NF'",
"terminal.integrated.rendererType": "canvas",
"terminal.integrated.fontSize": 13,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
brew list:
aws-iam-authenticator
gettext
kops
node
protobuf
tfswitch
awscli
git
kubectx
ntfs-3g
python
tree
azure-cli
go
kubernetes-cli
openssl
python@3.8
xz
eksctl
helm
kubernetes-helm
openssl@1.1
readline
z
gdbm
icu4c
linkerd
pcre2
sqlite
zsh-syntax-highlighting