diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 9d60963c..f1c8cd29 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -6280,8 +6280,13 @@ _p9k_dump_instant_prompt() { out+="$cr${(pl:$((height-prompt_height))::\n:)}$terminfo[sc]$out" fi fi - typeset -g __p9k_instant_prompt_output=${TMPDIR:-/tmp}/p10k-instant-prompt-output-${(%):-%n}-$$ - { echo -n > $__p9k_instant_prompt_output } || return + if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then + local tmpdir=$TMPDIR + else + local tmpdir=/tmp + fi + typeset -g __p9k_instant_prompt_output=$tmpdir/p10k-instant-prompt-output-${(%):-%n}-$$ + { : > $__p9k_instant_prompt_output } || return print -rn -- "${out}${esc}?2004h" || return if (( $+commands[stty] )); then command stty -icanon 2>/dev/null @@ -7802,7 +7807,12 @@ function _p9k_wrap_widgets() { # There is no zle-line-pre-redraw in zsh < 5.3, so we have to wrap all widgets # with key bindings. This costs extra 3ms: 1.5ms to fetch the list of widgets and # another 1.5ms to wrap them. - local keymap tmp=${TMPDIR:-/tmp}/p10k.bindings.$sysparams[pid] + if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then + local tmpdir=$TMPDIR + else + local tmpdir=/tmp + fi + local keymap tmp=$tmpdir/p10k.bindings.$sysparams[pid] { for keymap in $keymaps; do bindkey -M $keymap; done >$tmp local -aU widget_list=( @@ -8259,7 +8269,7 @@ _p9k_must_init() { [[ $sig == $_p9k__param_sig ]] && return 1 _p9k_deinit fi - _p9k__param_pat=$'v133\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' + _p9k__param_pat=$'v134\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1' _p9k__param_pat+=$__p9k_force_term_shell_integration$'\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 62564486..5d6215a7 100644 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1537,9 +1537,16 @@ function ask_config_overwrite() { case $choice in r) return 1;; y) - config_backup="$(mktemp ${TMPDIR:-/tmp}/$__p9k_cfg_basename.XXXXXXXXXX)" || quit -c + if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then + local tmpdir=$TMPDIR + local tmpdir_u='$TMPDIR' + else + local tmpdir=/tmp + local tmpdir_u=/tmp + fi + config_backup="$(mktemp $tmpdir/$__p9k_cfg_basename.XXXXXXXXXX)" || quit -c cp $__p9k_cfg_path $config_backup || quit -c - config_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)config_backup:t} + config_backup_u=$tmpdir_u/${(q-)config_backup:t} ;; esac return 0 @@ -1600,16 +1607,23 @@ function ask_zshrc_edit() { y) write_zshrc=1 if [[ -n $zshrc_content ]]; then - zshrc_backup="$(mktemp ${TMPDIR:-/tmp}/.zshrc.XXXXXXXXXX)" || quit -c - cp -p $__p9k_zshrc $zshrc_backup || quit -c + if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then + local tmpdir=$TMPDIR + local tmpdir_u='$TMPDIR' + else + local tmpdir=/tmp + local tmpdir_u=/tmp + fi + zshrc_backup="$(mktemp $tmpdir/.zshrc.XXXXXXXXXX)" || quit -c + cp -p $__p9k_zshrc $zshrc_backup || quit -c local -i writable=1 if [[ ! -w $zshrc_backup ]]; then - chmod u+w -- $zshrc_backup || quit -c + chmod u+w -- $zshrc_backup || quit -c writable=0 fi - print -r -- $zshrc_content >$zshrc_backup || quit -c - (( writable )) || chmod u-w -- $zshrc_backup || quit -c - zshrc_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)zshrc_backup:t} + print -r -- $zshrc_content >$zshrc_backup || quit -c + (( writable )) || chmod u-w -- $zshrc_backup || quit -c + zshrc_backup_u=$tmpdir_u/${(q-)zshrc_backup:t} fi ;; esac diff --git a/internal/worker.zsh b/internal/worker.zsh index 8eb21af3..269e8aad 100644 --- a/internal/worker.zsh +++ b/internal/worker.zsh @@ -181,7 +181,13 @@ function _p9k_worker_start() { setopt monitor || return { [[ -n $_p9k__worker_resp_fd ]] && return - _p9k__worker_file_prefix=${TMPDIR:-/tmp}/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS + + if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then + local tmpdir=$TMPDIR + else + local tmpdir=/tmp + fi + _p9k__worker_file_prefix=$tmpdir/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS sysopen -r -o cloexec -u _p9k__worker_resp_fd <( exec 0