1diff --git a/plugins/screen/screen.plugin.zsh b/plugins/screen/screen.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..ba7ac67e71e6f3b2bb000d4e39e94ca8a2c10e4c
4--- /dev/null
5+++ b/plugins/screen/screen.plugin.zsh
6@@ -0,0 +1,54 @@
7+# if using GNU screen, let the zsh tell screen what the title and hardstatus
8+# of the tab window should be.
9+if [[ $TERM == "screen" ]]; then
10+ if [[ $_GET_PATH == '' ]]; then
11+ _GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^~$USER/~/"'
12+ fi
13+ if [[ $_GET_HOST == '' ]]; then
14+ _GET_HOST='echo $HOST | sed "s/\..*//"'
15+ fi
16+
17+ # use the current user as the prefix of the current tab title
18+ TAB_TITLE_PREFIX='"`'$_GET_HOST'`:`'$_GET_PATH' | sed "s:..*/::"`$PROMPT_CHAR"'
19+ # when at the shell prompt, show a truncated version of the current path (with
20+ # standard ~ replacement) as the rest of the title.
21+ TAB_TITLE_PROMPT='$SHELL:t'
22+ # when running a command, show the title of the command as the rest of the
23+ # title (truncate to drop the path to the command)
24+ TAB_TITLE_EXEC='$cmd[1]:t'
25+
26+ # use the current path (with standard ~ replacement) in square brackets as the
27+ # prefix of the tab window hardstatus.
28+ TAB_HARDSTATUS_PREFIX='"[`'$_GET_PATH'`] "'
29+ # when at the shell prompt, use the shell name (truncated to remove the path to
30+ # the shell) as the rest of the title
31+ TAB_HARDSTATUS_PROMPT='$SHELL:t'
32+ # when running a command, show the command name and arguments as the rest of
33+ # the title
34+ TAB_HARDSTATUS_EXEC='$cmd'
35+
36+ # tell GNU screen what the tab window title ($1) and the hardstatus($2) should be
37+ function screen_set()
38+ {
39+ # set the tab window title (%t) for screen
40+ print -nR $'\033k'$1$'\033'\\\
41+
42+ # set hardstatus of tab window (%h) for screen
43+ print -nR $'\033]0;'$2$'\a'
44+ }
45+ # called by zsh before executing a command
46+ function preexec()
47+ {
48+ local -a cmd; cmd=(${(z)1}) # the command string
49+ eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_EXEC"
50+ eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_EXEC"
51+ screen_set $tab_title $tab_hardstatus
52+ }
53+ # called by zsh before showing the prompt
54+ function precmd()
55+ {
56+ eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_PROMPT"
57+ eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_PROMPT"
58+ screen_set $tab_title $tab_hardstatus
59+ }
60+fi