Move screen support to partial
This commit is contained in:
parent
ac77e7dfdb
commit
e56ca195f7
54
zsh.d/screen.zsh
Normal file
54
zsh.d/screen.zsh
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# vim: ft=zsh
|
||||||
|
|
||||||
|
function title {
|
||||||
|
# param: title to use
|
||||||
|
|
||||||
|
local prefix=''
|
||||||
|
|
||||||
|
# If I'm in a screen, all the windows are probably on the same machine, so
|
||||||
|
# I don't really need to title every single one with the machine name.
|
||||||
|
# On the other hand, if I'm not logged in as me (but, e.g., root), I'd
|
||||||
|
# certainly like to know that!
|
||||||
|
if [[ $USER != "$DEFAULT_USER" ]]; then
|
||||||
|
prefix="[$USER] "
|
||||||
|
fi
|
||||||
|
# Set screen window title
|
||||||
|
if [[ $TERM == "screen"* ]]; then
|
||||||
|
print -n "\ek$prefix$1\e\\"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prefix the xterm title with the current machine name, but only if I'm not
|
||||||
|
# on a local machine. This is tricky, because screen won't reliably know
|
||||||
|
# whether I'm using SSH right now! So just assume I'm local iff I'm not
|
||||||
|
# running over SSH *and* not using screen. Local screens are fairly rare.
|
||||||
|
prefix=$HOST
|
||||||
|
if [[ $SSH_CONNECTION == '' && $TERM != "screen"* ]]; then
|
||||||
|
prefix=''
|
||||||
|
fi
|
||||||
|
# If we're showing host and not default user prepend it
|
||||||
|
if [[ $prefix != '' && $USER != "$DEFAULT_USER" ]]; then
|
||||||
|
prefix="$USER@$prefix"
|
||||||
|
fi
|
||||||
|
# Wrap it in brackets
|
||||||
|
if [[ $prefix != '' ]]; then
|
||||||
|
prefix="[$prefix] "
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set xterm window title
|
||||||
|
if [[ $TERM == "xterm"* || $TERM == "screen"* ]]; then
|
||||||
|
print -n "\e]2;$prefix$1\a"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function title_precmd {
|
||||||
|
# Shorten homedir back to '~'
|
||||||
|
local shortpwd=${PWD/$HOME/\~}
|
||||||
|
title "zsh $shortpwd"
|
||||||
|
}
|
||||||
|
|
||||||
|
function title_preexec {
|
||||||
|
title $*
|
||||||
|
}
|
||||||
|
|
||||||
|
add-zsh-hook preexec title_preexec
|
||||||
|
add-zsh-hook precmd title_precmd
|
||||||
55
zshrc
55
zshrc
@ -372,61 +372,6 @@ function +vi-git-additional() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#---------------------------------- Screen ------------------------------------
|
|
||||||
|
|
||||||
function title {
|
|
||||||
# param: title to use
|
|
||||||
|
|
||||||
local prefix=''
|
|
||||||
|
|
||||||
# If I'm in a screen, all the windows are probably on the same machine, so
|
|
||||||
# I don't really need to title every single one with the machine name.
|
|
||||||
# On the other hand, if I'm not logged in as me (but, e.g., root), I'd
|
|
||||||
# certainly like to know that!
|
|
||||||
if [[ $USER != "$DEFAULT_USER" ]]; then
|
|
||||||
prefix="[$USER] "
|
|
||||||
fi
|
|
||||||
# Set screen window title
|
|
||||||
if [[ $TERM == "screen"* ]]; then
|
|
||||||
print -n "\ek$prefix$1\e\\"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Prefix the xterm title with the current machine name, but only if I'm not
|
|
||||||
# on a local machine. This is tricky, because screen won't reliably know
|
|
||||||
# whether I'm using SSH right now! So just assume I'm local iff I'm not
|
|
||||||
# running over SSH *and* not using screen. Local screens are fairly rare.
|
|
||||||
prefix=$HOST
|
|
||||||
if [[ $SSH_CONNECTION == '' && $TERM != "screen"* ]]; then
|
|
||||||
prefix=''
|
|
||||||
fi
|
|
||||||
# If we're showing host and not default user prepend it
|
|
||||||
if [[ $prefix != '' && $USER != "$DEFAULT_USER" ]]; then
|
|
||||||
prefix="$USER@$prefix"
|
|
||||||
fi
|
|
||||||
# Wrap it in brackets
|
|
||||||
if [[ $prefix != '' ]]; then
|
|
||||||
prefix="[$prefix] "
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set xterm window title
|
|
||||||
if [[ $TERM == "xterm"* || $TERM == "screen"* ]]; then
|
|
||||||
print -n "\e]2;$prefix$1\a"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function title_precmd {
|
|
||||||
# Shorten homedir back to '~'
|
|
||||||
local shortpwd=${PWD/$HOME/\~}
|
|
||||||
title "zsh $shortpwd"
|
|
||||||
}
|
|
||||||
|
|
||||||
function title_preexec {
|
|
||||||
title $*
|
|
||||||
}
|
|
||||||
|
|
||||||
add-zsh-hook preexec title_preexec
|
|
||||||
add-zsh-hook precmd title_precmd
|
|
||||||
|
|
||||||
#---------------------------------- Aliases ----------------------------------
|
#---------------------------------- Aliases ----------------------------------
|
||||||
|
|
||||||
# Use interactive sudo instead of su
|
# Use interactive sudo instead of su
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user