plugins/xterm: not just Xterm
parent
66dae7ca82
commit
4cb7453e90
|
|
@ -2,7 +2,7 @@
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'automatically set your xterm title with host and location info'
|
about-plugin 'automatically set your xterm title with host and location info'
|
||||||
|
|
||||||
_short-dirname() {
|
function _short-dirname() {
|
||||||
local dir_name="${PWD/~/\~}"
|
local dir_name="${PWD/~/\~}"
|
||||||
if [[ "${SHORT_TERM_LINE:-}" == true && "${#dir_name}" -gt 8 ]]; then
|
if [[ "${SHORT_TERM_LINE:-}" == true && "${#dir_name}" -gt 8 ]]; then
|
||||||
echo "${dir_name##*/}"
|
echo "${dir_name##*/}"
|
||||||
|
|
@ -11,7 +11,7 @@ _short-dirname() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_short-command() {
|
function _short-command() {
|
||||||
local input_command="$*"
|
local input_command="$*"
|
||||||
if [[ "${SHORT_TERM_LINE:-}" == true && "${#input_command}" -gt 8 ]]; then
|
if [[ "${SHORT_TERM_LINE:-}" == true && "${#input_command}" -gt 8 ]]; then
|
||||||
echo "${input_command%% *}"
|
echo "${input_command%% *}"
|
||||||
|
|
@ -20,16 +20,16 @@ _short-command() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
set_xterm_title() {
|
function set_xterm_title() {
|
||||||
local title="${1:-}"
|
local title="${1:-}"
|
||||||
echo -ne "\033]0;${title}\007"
|
echo -ne "\033]0;${title}\007"
|
||||||
}
|
}
|
||||||
|
|
||||||
precmd_xterm_title() {
|
function precmd_xterm_title() {
|
||||||
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) ${PROMPT_CHAR:-\$}"
|
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) ${PROMPT_CHAR:-\$}"
|
||||||
}
|
}
|
||||||
|
|
||||||
preexec_xterm_title() {
|
function preexec_xterm_title() {
|
||||||
local command_line="${BASH_COMMAND:-${1:-}}"
|
local command_line="${BASH_COMMAND:-${1:-}}"
|
||||||
local directory_name short_command
|
local directory_name short_command
|
||||||
directory_name="$(_short-dirname)"
|
directory_name="$(_short-dirname)"
|
||||||
|
|
@ -38,8 +38,8 @@ preexec_xterm_title() {
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${TERM:-dumb}" in
|
case "${TERM:-dumb}" in
|
||||||
xterm* | rxvt*)
|
xterm* | rxvt* | gnome-terminal | konsole | zvt | dtterm | kterm | Eterm | zterm)
|
||||||
precmd_functions+=(precmd_xterm_title)
|
safe_append_prompt_command 'precmd_xterm_title'
|
||||||
preexec_functions+=(preexec_xterm_title)
|
safe_append_preexec 'preexec_xterm_title'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue