Last active
September 14, 2021 14:20
-
-
Save susanBuck/b83bdde2b173b829a78e52b6fb02576f to your computer and use it in GitHub Desktop.
.zshrc example
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
# ------------------------------------ | |
# MOTD (Message of the Day) | |
# What you see when Terminal opens | |
# ------------------------------------ | |
echo "----------------------------" | |
echo "Loaded config: ~/.zshrc" | |
echo "" | |
echo "To edit run: configedit" | |
echo "To refresh run: configrefresh" | |
echo "List all aliases: alias" | |
echo "----------------------------" | |
# ------------------------------------ | |
# Configure prompt | |
# Includes special handling for git repos | |
# Ref: https://salferrarello.com/zsh-git-status-prompt/ | |
# ------------------------------------ | |
# Autoload zsh add-zsh-hook and vcs_info functions (-U autoload w/o substition, -z use zsh style) | |
autoload -Uz add-zsh-hook vcs_info | |
# Enable substitution in the prompt | |
setopt prompt_subst | |
# Run vcs_info just before a prompt is displayed (precmd) | |
add-zsh-hook precmd vcs_info | |
# Enable checking for (un)staged changes, enabling use of %u and %c | |
zstyle ':vcs_info:*' check-for-changes true | |
# Set custom strings for an unstaged vcs repo changes (*) and staged changes (+) | |
zstyle ':vcs_info:*' unstagedstr '%F{red} *%F{black}' | |
zstyle ':vcs_info:*' stagedstr '%F{green} +%F{black}' | |
# Set the format of the Git information for vcs_info | |
zstyle ':vcs_info:git:*' formats '(%b%u%c)' | |
zstyle ':vcs_info:git:*' actionformats '(%b|%a%u%c)' | |
# Design the prompt | |
PROMPT='%F{magenta}%/ %F{black}${vcs_info_msg_0_}%f %F{black}$ ' | |
# / shows the current path | |
# List of other placeholders you can use: | |
# https://zsh.sourceforge.io/Doc/Release/Prompt-Expansion.html#Prompt-Expansion | |
# ------------------------------------ | |
# ALIASES | |
# ------------------------------------ | |
# Edit .zshrc | |
alias configedit='sudo code ~/.zshrc' | |
# Force terminal to recognize changes to .zshrc | |
alias configrefresh='source ~/.zshrc' | |
# Ideal directory listing | |
alias ll="ls -laFG" | |
# Ask before removing files | |
alias rm='rm -i' | |
# Add your own aliases here... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment