[ADD] Use my own script to display terminal title
The provided 'vte.sh' script doesn't quite work on Bash because $HOSTNAME is empty for some reason.
This commit is contained in:
parent
4df55b8835
commit
173a0b093c
10
bash/.bashrc
10
bash/.bashrc
|
@ -6,14 +6,8 @@
|
|||
[[ $- != *i* ]] && return
|
||||
|
||||
# Export our directory to Termite for opening new terminals
|
||||
if { [[ "$TERM" == xterm-termite ]] || [[ "$TERM" == xterm ]]; } &&
|
||||
[ -r /etc/profile.d/vte.sh ]; then
|
||||
if [[ "$TERM" == xterm ]]; then # FIXME: hack to make Xterm work
|
||||
VTE_VERSION="${VTE_VERSION:-3405}"
|
||||
fi
|
||||
|
||||
. /etc/profile.d/vte.sh
|
||||
__vte_prompt_command
|
||||
if { [[ "$TERM" == xterm-termite ]] || [[ "$TERM" == xterm ]]; }; then
|
||||
source ~/.scripts/term-title
|
||||
fi
|
||||
|
||||
# Make colorcoding available for everyone
|
||||
|
|
45
scripts/term-title
Normal file
45
scripts/term-title
Normal file
|
@ -0,0 +1,45 @@
|
|||
# A script to display $USER@$HOST:$PWD with PWD shortened in terminal title
|
||||
# Taken mostly verbatim from 'vte.sh' provided with VTE-based shells
|
||||
|
||||
__term_title_urlencode() (
|
||||
# This is important to make sure string manipulation is handled
|
||||
# byte-by-byte.
|
||||
LC_ALL=C
|
||||
str="$1"
|
||||
while [ -n "$str" ]; do
|
||||
safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
|
||||
printf "%s" "$safe"
|
||||
str="${str#"$safe"}"
|
||||
if [ -n "$str" ]; then
|
||||
printf "%%%02X" "'$str"
|
||||
str="${str#?}"
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
__term_title () {
|
||||
printf "\033]7;file://%s%s\033\\" "${HOST:-}" "$(__term_title_urlencode "${PWD}")"
|
||||
}
|
||||
|
||||
__term_title_prompt_command() {
|
||||
local pwd='~'
|
||||
[ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
|
||||
pwd="${pwd//[[:cntrl:]]}"
|
||||
if [ -n "$BASH_VERSION" ]; then
|
||||
if command -v hostname &>/dev/null; then
|
||||
export HOSTNAME="$(hostname)"
|
||||
export HOST="$HOSTNAME"
|
||||
fi
|
||||
fi
|
||||
printf "\033]0;%s@%s:%s\033\\%s" "${USER}" "${HOST%%.*}" "${pwd}" "$(__term_title)"
|
||||
}
|
||||
|
||||
case "$TERM" in
|
||||
xterm*|term_title*)
|
||||
[ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__term_title_prompt_command;$PROMPT_COMMAND"
|
||||
[ -n "$ZSH_VERSION" ] && precmd_functions+=(__term_title_prompt_command)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Launch it once to make sure we display the wanted title
|
||||
__term_title
|
|
@ -45,9 +45,6 @@ if { [ -n "$BASH_VERSION" ] && shopt -q login_shell; } ||
|
|||
|
||||
# Use my preferred pager settings for bat
|
||||
export BAT_PAGER="$PAGER $LESS"
|
||||
|
||||
# Fix terminal title which uses HOSTNAME instead of HOST
|
||||
export HOSTNAME="$HOST"
|
||||
fi
|
||||
|
||||
# Use keychain to handle ssh-agent, in interactive shell too
|
||||
|
|
11
zsh/.zshrc
11
zsh/.zshrc
|
@ -1,13 +1,6 @@
|
|||
# Export our directory to Termite for opening new terminals
|
||||
if { [[ "$TERM" == xterm-termite ]] || [[ "$TERM" == xterm ]]; } &&
|
||||
[ -r /etc/profile.d/vte.sh ]; then
|
||||
if [[ "$TERM" == xterm ]]; then # FIXME: hack to make Xterm work
|
||||
VTE_VERSION="${VTE_VERSION:-3405}"
|
||||
fi
|
||||
|
||||
. /etc/profile.d/vte.sh
|
||||
__vte_osc7
|
||||
precmd_functions+=(__vte_prompt_command) # FIXME: why isn't it set above ?
|
||||
if { [[ "$TERM" == xterm-termite ]] || [[ "$TERM" == xterm ]]; }; then
|
||||
source ~/.scripts/term-title
|
||||
fi
|
||||
|
||||
# History configuration
|
||||
|
|
Loading…
Reference in a new issue