Add zshrc
This commit is contained in:
commit
ae02cb425a
1 file changed
+56
@@ -0,0 +1,56 @@
|
|||||||
|
autoload -U colors && colors
|
||||||
|
|
||||||
|
USER_COLOR="%F{magenta}"
|
||||||
|
VENV_COLOR="%F{yellow}"
|
||||||
|
DIR_COLOR="%F{green}"
|
||||||
|
GIT_COLOR="%F{blue}"
|
||||||
|
GIT_DIRTY_COLOR="%F{red}"
|
||||||
|
PROMPT_SYMBOL_COLOR="%F{yellow}"
|
||||||
|
RESET_COLOR="%f"
|
||||||
|
|
||||||
|
shorten_path() {
|
||||||
|
local path="${PWD/#$HOME/~}"
|
||||||
|
local parts=("${(@s:/:)path}")
|
||||||
|
|
||||||
|
if (( ${#parts} > 3 )); then
|
||||||
|
echo "${parts[1]}/.../${parts[-2]}/${parts[-1]}"
|
||||||
|
else
|
||||||
|
echo "$path"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
git_branch() {
|
||||||
|
local branch
|
||||||
|
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
||||||
|
[[ -n "$branch" ]] && echo "$branch"
|
||||||
|
}
|
||||||
|
|
||||||
|
git_dirty() {
|
||||||
|
[[ -n "$(git status --porcelain 2>/dev/null)" ]] && echo "✗" || echo "✓"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_prompt() {
|
||||||
|
local user="${USER_COLOR}%n${RESET_COLOR}"
|
||||||
|
local venv=""
|
||||||
|
[[ -n "$VIRTUAL_ENV" ]] && venv="${VENV_COLOR}($(basename $VIRTUAL_ENV))${RESET_COLOR} "
|
||||||
|
|
||||||
|
local path="${DIR_COLOR}$(shorten_path)${RESET_COLOR}"
|
||||||
|
local git_info=""
|
||||||
|
local branch="$(git_branch)"
|
||||||
|
|
||||||
|
if [[ -n "$branch" ]]; then
|
||||||
|
git_info=" %F{white}on%f ${GIT_COLOR}${branch}${RESET_COLOR}${GIT_DIRTY_COLOR}$(git_dirty)${RESET_COLOR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROMPT="${user} %F{white}in%f ${venv}${path}${git_info}
|
||||||
|
${PROMPT_SYMBOL_COLOR}λ${RESET_COLOR} "
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook precmd set_prompt
|
||||||
|
|
||||||
|
export PATH="$PATH:$HOME/.local/bin"
|
||||||
|
|
||||||
|
alias gvc="ssh git@git.venomade.com"
|
||||||
|
|
||||||
|
alias rgf='rg --files | rg'
|
||||||
Reference in new issue
Block a user