Skip to content

Instantly share code, notes, and snippets.

@hesenger
Last active January 16, 2024 12:48
Show Gist options
  • Save hesenger/ce0b94aea2ae7fe2a339835040b8b89a to your computer and use it in GitHub Desktop.
Save hesenger/ce0b94aea2ae7fe2a339835040b8b89a to your computer and use it in GitHub Desktop.
.zshrc
# case insensitive complete
autoload -Uz compinit && compinit
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# prompt
custom_prompt() {
local current_time="%F{cyan}$(date +%H:%M:%S)%f"
local current_folder="%B${PWD##*/}%b"
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
local git_branch="$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)"
echo "${current_time} ${current_folder} (${git_branch}) \$ "
else
echo "${current_time} ${current_folder} \$ "
fi
}
setopt PROMPT_SUBST
PS1='$(custom_prompt)'
@hesenger
Copy link
Author

tired of not being instant when opening a fresh tab after install oh-my-zsh, so tried to adapt functionality while keeping the script maintainable and the output cleaner

additionally not adding export=$PATH:... to the .zshrc but rather to .zprofile so executables are loaded at startup instead of terminal sessions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment