mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 16:50:58 +01:00
Use preexec hook to replace "fg" et al. with the jobtext of the resumed job.
This commit is contained in:
parent
ecb6967236
commit
fdcabaf507
1 changed files with 27 additions and 2 deletions
|
|
@ -67,14 +67,37 @@ prompt_bart_help () {
|
|||
}
|
||||
|
||||
integer PSCOL=1
|
||||
typeset PSCMD=
|
||||
|
||||
prompt_bart_preexec () {
|
||||
setopt localoptions noxtrace noksharrays unset
|
||||
local -a cmd; cmd=( ${(z)3} )
|
||||
if [[ $cmd[1] = fg ]]
|
||||
then
|
||||
shift cmd
|
||||
cmd[1]=${cmd[1]:-%+}
|
||||
fi
|
||||
if [[ $#cmd -eq 1 && $cmd[1] = %* ]]
|
||||
then
|
||||
PSCMD=$jobtexts[$cmd[1]]
|
||||
elif [[ -o autoresume && -n $jobtexts[%?$2] ]]
|
||||
then
|
||||
PSCMD=$jobtexts[%?$2]
|
||||
else
|
||||
PSCMD=$2
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
prompt_bart_precmd () {
|
||||
setopt localoptions noxtrace noksharrays unset
|
||||
local zero='%([BSUbfksu]|[FB]{*})' escape colno lineno
|
||||
|
||||
: "${PSCMD:=$history[$[HISTCMD-1]]}" # Default to history text
|
||||
|
||||
# Using psvar here protects against unwanted promptsubst expansions.
|
||||
|
||||
psvar[7]="$history[$[HISTCMD-1]]" # Use history text, not just number
|
||||
psvar[7]="$PSCMD"
|
||||
psvar[8]='' # No padding until we compute it
|
||||
psvar[9]=()
|
||||
|
||||
|
|
@ -153,6 +176,7 @@ prompt_bart_setup () {
|
|||
repeat 1 case "$1:l" in
|
||||
(off|disable)
|
||||
add-zsh-hook -D precmd "prompt_*_precmd"
|
||||
add-zsh-hook -D preexec "prompt_*_preexec"
|
||||
functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}"
|
||||
[[ $prompt_theme[1] = bart ]] && PS1=${${(f)PS1}[-1]}
|
||||
return 1
|
||||
|
|
@ -182,6 +206,7 @@ prompt_bart_setup () {
|
|||
# Paste our special commands into precmd and TRAPWINCH
|
||||
|
||||
add-zsh-hook precmd prompt_bart_precmd
|
||||
add-zsh-hook preexec prompt_bart_preexec
|
||||
functions[TRAPWINCH]="${functions[TRAPWINCH]//prompt_bart_winch}
|
||||
prompt_bart_winch"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue