mirror of
https://github.com/Smaug123/nix-dotfiles
synced 2025-10-06 06:58:41 +00:00
33 lines
878 B
Bash
33 lines
878 B
Bash
prompt_custom() {
|
|
local cyan='%F{cyan}'
|
|
local red='%F{red}'
|
|
local blue='%F{blue}'
|
|
local reset_color='%f'
|
|
|
|
local git_info=$(git symbolic-ref --short HEAD 2> /dev/null || git describe --tags --exact-match 2> /dev/null || git rev-parse --short HEAD 2> /dev/null)
|
|
if [[ -n "$git_info" ]]; then
|
|
# escape the percent character, which is the only zsh prompt metacharacter
|
|
git_info=$git_info:s/%/%%/
|
|
git_info=" ${blue}git:${reset_color}${red}(${git_info})${reset_color}"
|
|
else
|
|
git_info=""
|
|
fi
|
|
|
|
# %1 is the name of cwd
|
|
PROMPT="${cyan}%1~${reset_color}${git_info} > "
|
|
}
|
|
|
|
# Full path to cwd, with `~` for any initial home component, in light green,
|
|
RPROMPT='%F{155}%~%f'
|
|
|
|
precmd_functions+=(prompt_custom)
|
|
|
|
export WORDCHARS=''
|
|
|
|
autoload edit-command-line
|
|
zle -N edit-command-line
|
|
bindkey '^X^E' edit-command-line
|
|
bindkey -e
|
|
|
|
PATH="$PATH:$HOME/.cargo/bin"
|