Last active
February 15, 2017 12:22
-
-
Save mgor/db27421f928d11363d48ef869f4c1be6 to your computer and use it in GitHub Desktop.
Set screen window title based on the command that is being executed (trying to "emulate" tmux automatic set title). This will leave the window title to the last executed command though.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if [[ "${TERM}" == screen* ]]; then | |
| preexec() { :; } | |
| screen_window_title() { | |
| [[ -n "${COMP_LINE}" ]] && return | |
| [[ "${BASH_COMMAND}" == "${PROMPT_COMMAND}" ]] && return | |
| local cmd=$(HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//") | |
| local title="${cmd}" | |
| (( "${#title}" > 12 )) && title="${title:0:12}..." | |
| printf '\ek%s\e\\' "${title}" | |
| preexec "${cmd}" | |
| } | |
| trap 'screen_window_title' DEBUG | |
| fi | |
| stty -ixon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment