# currently running program.
#
# When a program is started preexec() sets the window's name to it; when it
-# stops precmd() resets the window's name to 'zsh'.
+# stops precmd() resets the window's name to 'zsh'. 'fg' is supported and sets
+# the window's name to the resumed job.
#
# It works with screen, xterm and rxvt.
#
program_name=${program_name#sudo }
program_sudo=yes
fi
+
+ # Replace fg with the resumed job name.
+ if [[ $program_name == fg ]]; then
+ program_name=${jobtexts[%+]}
+ elif [[ $program_name == fg* ]]; then
+ program_name=${jobtexts[${program_name#fg }]}
+ fi
+
# Remove all arguments from the program name.
program_name=${program_name%% *}