Allow excluding directories from starship's git status module
This commit is contained in:
parent
b8e8ec9cd6
commit
1f110837c6
31
init.zsh
31
init.zsh
@ -139,7 +139,7 @@ SPACESHIP_PACKAGE_SYMBOL=" "
|
|||||||
autoload -U promptinit && promptinit
|
autoload -U promptinit && promptinit
|
||||||
prompt spaceship
|
prompt spaceship
|
||||||
# Change cursor shape for different vi modes.
|
# Change cursor shape for different vi modes.
|
||||||
function zle-line-init zle-keymap-select {
|
function __zsh_vim_key_prompt_handler {
|
||||||
SPACESHIP_CHAR_SYMBOL="❮"
|
SPACESHIP_CHAR_SYMBOL="❮"
|
||||||
local _shape=0
|
local _shape=0
|
||||||
case "${KEYMAP}" in
|
case "${KEYMAP}" in
|
||||||
@ -157,9 +157,37 @@ function zle-line-init zle-keymap-select {
|
|||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
printf '\e[%d q' "${_shape}"
|
printf '\e[%d q' "${_shape}"
|
||||||
}
|
}
|
||||||
|
function __zsh_check_disabled_git_prompt_dirs {
|
||||||
|
local excluded=false
|
||||||
|
for file in ${(s:\0:)__ZSH_PROMPT_EXCLUDE_GIT_STATUS}; do
|
||||||
|
if [[ "${PWD:P}/" = "${file}/"* ]]; then
|
||||||
|
SPACESHIP_GIT_STATUS_SHOW=false
|
||||||
|
excluded=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ! $excluded; then
|
||||||
|
SPACESHIP_GIT_STATUS_SHOW=true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function chpwd {
|
||||||
|
__zsh_check_disabled_git_prompt_dirs
|
||||||
|
}
|
||||||
|
function zle-line-init {
|
||||||
|
__zsh_vim_key_prompt_handler
|
||||||
|
}
|
||||||
|
function zle-keymap-select {
|
||||||
|
__zsh_vim_key_prompt_handler
|
||||||
|
}
|
||||||
zle -N zle-keymap-select
|
zle -N zle-keymap-select
|
||||||
zle -N zle-line-init
|
zle -N zle-line-init
|
||||||
|
|
||||||
|
# Exclude DIR from spaceship's git status module
|
||||||
|
# prompt_exclude_git_status <dir>
|
||||||
|
function prompt_exclude_git_status {
|
||||||
|
__ZSH_PROMPT_EXCLUDE_GIT_STATUS="${__ZSH_PROMPT_EXCLUDE_GIT_STATUS}\0${1:P}"
|
||||||
|
}
|
||||||
|
|
||||||
# Bookmarks
|
# Bookmarks
|
||||||
[ -v ZSH_BOOKMARK_DIR ] || ZSH_BOOKMARK_DIR="${HOME}/.cache/zsh/bookmarks"
|
[ -v ZSH_BOOKMARK_DIR ] || ZSH_BOOKMARK_DIR="${HOME}/.cache/zsh/bookmarks"
|
||||||
[ -v ZSH_BOOKMARK_LS ] || ZSH_BOOKMARK_LS=true
|
[ -v ZSH_BOOKMARK_LS ] || ZSH_BOOKMARK_LS=true
|
||||||
@ -209,6 +237,7 @@ setopt histignoredups
|
|||||||
|
|
||||||
# Clean up internal functions
|
# Clean up internal functions
|
||||||
unfunction load_plugin
|
unfunction load_plugin
|
||||||
|
unfunction prompt_exclude_git_status
|
||||||
|
|
||||||
# Run fortune and cowsay if we are not in nvim
|
# Run fortune and cowsay if we are not in nvim
|
||||||
[[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n
|
[[ -v NVIM ]] || fortune | cowsay -felephant-in-snake -n
|
||||||
|
Loading…
Reference in New Issue
Block a user