Last active
March 23, 2021 20:54
-
-
Save mabbouxj/91f6156ebeb788c59a49399c6f298dad 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
export ZSH="$HOME/.oh-my-zsh" | |
export PATH="$HOME/bin:$PATH" | |
ZSH_THEME="gnzh-custom" | |
HYPHEN_INSENSITIVE="true" | |
ENABLE_CORRECTION="false" | |
COMPLETION_WAITING_DOTS="true" | |
HIST_STAMPS="yyyy-mm-dd" | |
ZSH_DISABLE_COMPFIX="true" | |
plugins=( | |
git | |
common-aliases | |
vscode | |
zsh-autosuggestions | |
command-not-found | |
) | |
source $ZSH/oh-my-zsh.sh | |
# User configuration | |
export EDITOR=vim | |
export SSH_KEY_PATH="~/.ssh/rsa_id" | |
function rpromptExitStatus() { | |
local exit_code=$? | |
local res="" | |
if [ $exit_code -eq 127 ]; then res="Not found -" | |
elif [ $exit_code -eq 130 ]; then res="Cancelled -" | |
elif [ $exit_code -eq 137 ]; then res="Killed -" | |
elif [ $exit_code -gt 128 ]; then res="Stopped [$(($exit_code - 128))] -" | |
fi | |
echo "${res}" | |
} | |
function getElapsedTime() { | |
local now=$(date +%s%3N) | |
if [[ `uname` == "Darwin" ]]; then | |
now=$(date +%s%3) | |
fi | |
local d_ms=$(($now-$timer)) | |
local d_s=$((d_ms / 1000)) | |
local ms=$((d_ms % 1000)) | |
local s=$((d_s % 60)) | |
local m=$(((d_s / 60) % 60)) | |
local h=$((d_s / 3600)) | |
local elapsed=d_ms | |
if ((h > 0)); then elapsed=${h}h${m}m | |
elif ((m > 0)); then elapsed=${m}m${s}s | |
elif ((s >= 10)); then elapsed=${s}.$((ms / 100))s | |
elif ((s > 0)); then elapsed=${s}.$((ms / 10))s | |
else elapsed=${ms}ms | |
fi | |
echo "${elapsed}" | |
} | |
function preexec() { | |
timer=$(date +%s%3N) | |
if [[ `uname` == "Darwin" ]]; then | |
timer=$(date +%s%3) | |
fi | |
} | |
function precmd() { | |
local r_exit_status=$(rpromptExitStatus) | |
if [ $timer ]; then | |
local elapsed=$(getElapsedTime) | |
export RPROMPT="%F{240}${r_exit_status} ${elapsed} %{$reset_color%}" | |
unset timer | |
else | |
export RPROMPT="" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment