Skip to content

Instantly share code, notes, and snippets.



Last active Feb 15, 2017
What would you like to do?
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.
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
stty -ixon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.