Set the terminal title like pure does (starship doesn't do this)
This commit is contained in:
parent
df87551b1e
commit
78208004a3
4 changed files with 36 additions and 0 deletions
27
config/zsh/functions/prompt_pure_set_title
Normal file
27
config/zsh/functions/prompt_pure_set_title
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#! zsh
|
||||||
|
# copied from https://github.com/sindresorhus/pure/blob/43aafe0b4dc05174c57ee623c03c64400e832ece/pure.zsh#L56
|
||||||
|
setopt localoptions noshwordsplit
|
||||||
|
|
||||||
|
# Emacs terminal does not support settings the title.
|
||||||
|
(( ${+EMACS} || ${+INSIDE_EMACS} )) && return
|
||||||
|
|
||||||
|
case $TTY in
|
||||||
|
# Don't set title over serial console.
|
||||||
|
/dev/ttyS[0-9]*) return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Show hostname if connected via SSH.
|
||||||
|
local hostname=
|
||||||
|
if [[ -n $prompt_pure_state[username] ]]; then
|
||||||
|
# Expand in-place in case ignore-escape is used.
|
||||||
|
hostname="${(%):-(%m) }"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local -a opts
|
||||||
|
case $1 in
|
||||||
|
expand-prompt) opts=(-P);;
|
||||||
|
ignore-escape) opts=(-r);;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Set title atomically in one print statement so that it works when XTRACE is enabled.
|
||||||
|
print -n $opts $'\e]0;'${hostname}${2}$'\a'
|
3
config/zsh/functions/starship_pure_title_precmd
Normal file
3
config/zsh/functions/starship_pure_title_precmd
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#! zsh
|
||||||
|
autoload prompt_pure_set_title
|
||||||
|
prompt_pure_set_title 'expand-prompt' '%~'
|
3
config/zsh/functions/starship_pure_title_preexec
Normal file
3
config/zsh/functions/starship_pure_title_preexec
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#! zsh
|
||||||
|
autoload prompt_pure_set_title
|
||||||
|
prompt_pure_set_title 'ignore-escape' "$PWD:t: $2"
|
|
@ -17,6 +17,9 @@ zinit $load rupa/z
|
||||||
|
|
||||||
if (( $+commands[starship] )); then
|
if (( $+commands[starship] )); then
|
||||||
source <(starship init zsh --print-full-init)
|
source <(starship init zsh --print-full-init)
|
||||||
|
autoload starship_pure_title_precmd starship_pure_title_preexec
|
||||||
|
precmd_functions+=(starship_pure_title_precmd)
|
||||||
|
preexec_functions+=(starship_pure_title_preexec)
|
||||||
else
|
else
|
||||||
zinit $load sindresorhus/pure
|
zinit $load sindresorhus/pure
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue