Created
April 6, 2021 21:10
-
-
Save rednebmas/86fd7e6a767eb0a15e63731e7de3ad9f to your computer and use it in GitHub Desktop.
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
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting | |
autoload -Uz compinit && compinit | |
# https://superuser.com/a/1092328 | |
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' | |
## | |
## Git | |
## | |
function gits() { git status } | |
function gitbr() { git branch } | |
function git-() { git co - } | |
## | |
## Prompt | |
## | |
autoload -Uz vcs_info | |
PROMPT_COLOR_1=9 | |
PROMPT_COLOR_2=15 # white | |
PROMPT_COLOR=$PROMPT_COLOR_1 | |
precmd_vcs_info() { vcs_info } | |
alternate_colors() { | |
if (($PROMPT_COLOR == $PROMPT_COLOR_1)); then | |
PROMPT_COLOR=$PROMPT_COLOR_2 | |
PROMPT='${NEWLINE}%F{${PROMPT_COLOR_2}}%1~'\$vcs_info_msg_0_' $ %b%F{10}' | |
else | |
PROMPT_COLOR=$PROMPT_COLOR_1 | |
PROMPT='${NEWLINE}%B%F{${PROMPT_COLOR_1}}%1~'\$vcs_info_msg_0_' $ %b%F{10}' | |
fi | |
} | |
precmd_functions=( precmd_vcs_info alternate_colors ) | |
setopt prompt_subst | |
zstyle ':vcs_info:git:*' formats ' (%b)' | |
NEWLINE=$'\n' | |
PROMPT='${NEWLINE}%F{${PROMPT_COLOR_1}}%1~'\$vcs_info_msg_0_' $ %F{10}' | |
## | |
## Path | |
## | |
## | |
## Restore working directory | |
## https://superuser.com/a/328148 | |
## | |
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then | |
update_terminal_cwd() { | |
# Identify the directory using a "file:" scheme URL, including | |
# the host name to disambiguate local vs. remote paths. | |
# Percent-encode the pathname. | |
local url_path='' | |
{ | |
# Use LC_CTYPE=C to process text byte-by-byte. Ensure that | |
# LC_ALL isn't set, so it doesn't interfere. | |
local i ch hexch LC_CTYPE=C LC_ALL= | |
for ((i = 1; i <= ${#PWD}; ++i)); do | |
ch="$PWD[i]" | |
if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then | |
url_path+="$ch" | |
else | |
printf -v hexch "%02X" "'$ch" | |
url_path+="%$hexch" | |
fi | |
done | |
} | |
printf '\e]7;%s\a' "file://$HOST$url_path" | |
} | |
# Register the function so it is called at each prompt. | |
autoload add-zsh-hook | |
add-zsh-hook precmd update_terminal_cwd | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment