summaryrefslogtreecommitdiffstats
path: root/bashrc/common/screen.sh
blob: 734ccfbe11393981b5941c6250362b5cc37df61a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# screen shelltitle magic

set_screen_title() {
    # prevent reset_screen_title from calling set_screen_title
    if [[ $BASH_COMMAND != "reset_screen_title" ]]; then
	echo -ne "\ek$(id -un)@$(hostname):${BASH_COMMAND/ *}\e\\"
    fi
}

reset_screen_title() {
    echo -ne "\ek$(id -un)@$(hostname)\e\\"
}

init_preexec_hack() {
    if [[ $TERM == "screen" ]]; then
	export PROMPT_COMMAND=reset_screen_title
	trap set_screen_title DEBUG
    fi
}