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