Use XDG base dir vars instead of defaults

This commit is contained in:
Kenneth Benzie (Benie)
2024-09-10 07:31:17 -07:00
parent 1e53581d17
commit 8812ef8544
5 changed files with 61 additions and 34 deletions

View File

@@ -56,7 +56,8 @@ prompt_fresh_setup() {
}
prompt_cleanup() {
[ -f ~/.cache/zsh/git-prompt ] && rm ~/.cache/zsh/git-prompt
[ -f ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt ] && \
rm ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt
}
fresh_line_one() {
@@ -76,7 +77,7 @@ fresh_line_one() {
local directory="%{%F{37}%}%~%{%f%}"
# Check we are in a git repository
local git=`~/.cache/zsh/git-prompt`
local git=`${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt`
# If the last command failed, display its error code at the right
if [[ $exit_code -ne 0 ]]; then
@@ -178,10 +179,12 @@ fresh_almostontop_preexec() {
fresh_compile_git_prompt() {
# Compile a simple C program which parses the output of `git status
# --procelain` to greatly decrease the time taken to draw the prompt
[ ! -d ~/.cache/zsh ] && mkdir -p ~/.cache/zsh
if [ ! -f ~/.cache/zsh/git-prompt ]; then
[ ! -d ${XDG_CACHE_HOME:-$HOME/.cache}/zsh ] && \
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/zsh
if [ ! -f ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt ]; then
cc -std=gnu99 -O3 -DNDEBUG -Wno-unused-result \
~/.config/zsh/git-prompt.c -o ~/.cache/zsh/git-prompt
${XDG_CONFIG_HOME:-$HOME/.config}/zsh/git-prompt.c \
-o ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/git-prompt
if [ $? -ne 0 ]; then
echo "git-prompt was not compiled, is a C99 toolchain installed?"
fi