Last active
March 12, 2021 18:27
-
-
Save tyhawkins/7bcef6e280688e362dbdf9a1aba54a94 to your computer and use it in GitHub Desktop.
Shell environment snippets
This file contains hidden or 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
# save as much history as possible | |
HISTFILE="$HOME/.zsh_history" | |
HISTSIZE=10000000 | |
SAVEHIST=10000000 | |
# zsh plugins | |
plugins=( | |
aws | |
docker | |
git | |
kubectl | |
kube-ps1 | |
rsync | |
terraform | |
) | |
# kube-ps1 prompt | |
PROMPT=$PROMPT'$(kube_ps1) ' | |
kubeoff | |
autoload -U compinit && compinit | |
export GPG_TTY=$(tty) | |
source $HOME/.aliases | |
if [ -z "$SSH_AUTH_SOCK" ] ; then | |
eval `ssh-agent -s` | |
ssh-add | |
fi | |
# my aliases | |
alias kctx='kubectx' | |
alias kns='kubens' | |
alias history='history -i' | |
alias tfaa='terraform apply --auto-approve' | |
## Add a timer and the time to the terminal | |
## replace gdate with date if running on a Linux system | |
# refreshes the prompt every $TMOUT seconds | |
TMOUT=15 | |
function preexec() { | |
timer=$(($(gdate +%s%0N)/1000000)) | |
} | |
function precmd() { | |
if [ $timer ]; then | |
now=$(($(gdate +%s%0N)/1000000)) | |
calculated=$(( $now-$timer )) | |
hours=$(( $calculated/1000/3600 )) | |
min=$(( $calculated/1000/60 )) | |
sec=$(( ($calculated/1000)%60 )) | |
if [[ "${calculated}" -le 1000 ]]; then | |
elapsed="%F{magenta}${calculated}ms" | |
elif [[ "${calculated}" -le 60000 ]]; then | |
elapsed="%F{green}$(( ${calculated} / 1000 ))s" | |
else | |
if [ "$hours" -gt 0 ]; then | |
min="$(( $min%60 ))" | |
elapsed="%F{red}${hours}h${min}m${sec}s" | |
else | |
elapsed="%F{yellow}${min}m${sec}s" | |
fi | |
fi | |
export RPROMPT="[${elapsed}%f] [%F{green}%D{%Y/%m/%f}%f|%F{cyan}%T%f]" | |
unset timer | |
fi | |
} | |
function TRAPALRM() { | |
zle reset-prompt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment