fix: more consistent terminal title

This commit is contained in:
Oscar Wallberg
2025-04-19 00:10:43 +02:00
parent fd54cf10d3
commit 6389b29173
2 changed files with 53 additions and 33 deletions
+8 -5
View File
@@ -211,13 +211,13 @@ providers=Genius, Lyrics.ovh, LoloLyrics, Musixmatch, songlyrics.com, azlyrics.c
[MainWindow]
current_tab=1
file_path=/home/oscar/Music
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\a\x80\0\0\0\0\0\0\x11\x7f\0\0\x5W\0\0\a\x81\0\0\0\x19\0\0\v\xeb\0\0\x2\xc5\0\0\0\x1\x2\0\0\0\n\0\0\0\a\x80\0\0\0\0\0\0\x11\x7f\0\0\x5W)
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\x11\x80\0\0\0\0\0\0\x18\xff\0\0\x4g\0\0\x11\x81\0\0\0\x19\0\0\x15\xeb\0\0\x2\xc5\0\0\0\x2\x2\0\0\0\a\x80\0\0\x11\x80\0\0\0\0\0\0\x18\xff\0\0\x4g)
hidden=false
maximized=true
minimized=false
search_for_cover_auto=true
show_sidebar=true
splitter_state=@ByteArray(\0\0\0\xff\0\0\0\x1\0\0\0\x2\0\0\x1\x36\0\0\x4W\0\xff\xff\xff\xff\x1\0\0\0\x1\0)
splitter_state=@ByteArray(\0\0\0\xff\0\0\0\x1\0\0\0\x2\0\0\x1\xbb\0\0\x5\xc4\0\xff\xff\xff\xff\x1\0\0\0\x1\0)
tab_collection=1
tab_context=0
tab_devices=7
@@ -280,14 +280,15 @@ remove_problematic=true
replace_spaces=false
[Player]
playback_playlist=-1
playback_position=0
playback_state=0
playback_playlist=1
playback_position=16
playback_state=3
volume=100
[Playlist]
alternating_row_colors=true
auto_sort=false
column_alignments=@Variant(\0\0\0\x7f\0\0\0\x13\x43olumnAlignmentMap\0\0\0\0\v\0\0\0\x6\0\0\0\x82\0\0\0\a\0\0\0\x82\0\0\0\b\0\0\0\x82\0\0\0\t\0\0\0\x82\0\0\0\n\0\0\0\x82\0\0\0\f\0\0\0\x82\0\0\0\r\0\0\0\x82\0\0\0\xe\0\0\0\x82\0\0\0\x11\0\0\0\x82\0\0\0\x15\0\0\0\x82\0\0\0\x16\0\0\0\x82)
continue_on_error=false
delete_files=false
editmetadatainline=false
@@ -300,6 +301,8 @@ rating_locked=false
select_track=false
show_bars=true
show_toolbar=true
state="@ByteArray(P,\x95\x10\x1\0\0\0 \0\0\0\b\0\0\0\0\0\0\0\x1\0\0\0\x2\0\0\0\x3\0\0\0\x4\0\0\0\x5\0\0\0\x6\0\0\0\a\0\0\0\t\0\0\0\n\0\0\0\v\0\0\0\f\0\0\0\r\0\0\0\xe\0\0\0\xf\0\0\0\x10\0\0\0\x11\0\0\0\x12\0\0\0\x13\0\0\0\x14\0\0\0\x15\0\0\0\x16\0\0\0\x17\0\0\0\x18\0\0\0\x19\0\0\0\x1a\0\0\0\x1b\0\0\0\x1c\0\0\0\x1d\0\0\0\x1e\0\0\0\x1f\0\0\0 \0\0\x1\x15\0\0\x1H\0\0\x1\x89\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0>\0\0\0\0\0\0\0\x42\0\0\0\0\0\0\0R\0\0\0?\0\0\0>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0:\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\n\0\0\0\0\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\n\0\0\0\f\0\0\0\r\0\0\0\xe\0\0\0\x12\0\0\0\x1a\0\0\0 ?\xc8i\xfb\xbd\xea\xca\xe2?\xcc\xdb\xf4\x8cW\x14\x41?\xd1P\xeb\xa0\xfd}\xec\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?\xa5\xe7\x62\xd6\xdboV\0\0\0\0\0\0\0\0?\xa7\x81\xd0T\xf5\xd3\xe0\0\0\0\0\0\0\0\0?\xac\xecp]\x1a\x64\xef?\xa6\x83\xa8>\xca\xd1\xf3?\xa5\xdd\x19\xddH\x18\x8d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?\xa5/\x9a\xe2_\xec\xc3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0?\xa4z\xe1G\xae\x14{\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0)"
state_version=1
warn_close_playlist=true
write_metadata=false
+44 -27
View File
@@ -4,7 +4,7 @@
_here="$(dirname -- "$(readlink -f -- "${HOME}/.zshrc")")"
_cache_dir="${XDG_CACHE_HOME:-"${HOME}/.cache"}/zsh"
if [[ ! -d "${_cache_dir}" ]]; then
if [[ ! -d ${_cache_dir} ]]; then
mkdir -p "${_cache_dir}"
fi
@@ -98,14 +98,14 @@ _antidote="${_cache_dir}/antidote"
_plugins="${_here}/plugins"
_plugins_cache="${_cache_dir}/plugins"
if [[ ! -d "$_antidote" ]]; then
if [[ ! -d $_antidote ]]; then
git clone --depth=1 https://github.com/mattmc3/antidote.git "$_antidote"
fi
fpath=("${_antidote}/functions" "${fpath[@]}")
autoload -Uz antidote
if [[ ! "${_plugins_cache}" -nt "${_plugins}" ]]; then
if [[ ! ${_plugins_cache} -nt ${_plugins} ]]; then
antidote bundle <"${_plugins}" >"${_plugins_cache}"
fi
@@ -119,19 +119,44 @@ unset _antidote _plugins _plugins_cache
# Ref: https://zsh.sourceforge.io/Doc/Release/Functions.html#Functions
function set_terminal_title() {
if [ -n "$SSH_CLIENT" ]; then
return
local title cwd host extra
local -a parts
extra="$1"
parts=()
if [ -n "$SSH_CONNECTION" ] && [ -z "$TMUX" ]; then
local -a tmp
tmp=("${=SSH_CONNECTION}")
host=${tmp[3]}
parts+=("$host")
fi
local title
if [ -z "$1" ]; then
title=$(basename "$(print -P "%~")")
if [ "$PWD" = "$HOME" ]; then
cwd="~"
else
title="$1"
cwd="${PWD##*/}"
fi
parts+=("$cwd")
if [ -n "$extra" ]; then
parts+=("$extra")
fi
# shellcheck disable=SC2296
title="${(j|:|)parts}"
echo -ne "\033]2;$title\033\\"
}
function preexec() {
local cmd
cmd=${1%% *}
set_terminal_title "$cmd"
}
function precmd() {
set_terminal_title
}
@@ -142,26 +167,18 @@ function telnet_with_title() {
for arg in "$@"; do
case "$arg" in
--bind=*)
;&
--escape=*)
;&
--user=*)
;&
--trace=*)
;&
--bind=*) ;&
--escape=*) ;&
--user=*) ;&
--trace=*) ;&
-[beln]?*)
# Option with argument immediately after, like -blocalhost
skip_next="false"
;;
--bind)
;&
--escape)
;&
--user)
;&
--trace)
;&
--bind) ;&
--escape) ;&
--user) ;&
--trace) ;&
-[beln])
# Option with argument on next iteration
skip_next="true"
@@ -182,7 +199,7 @@ function telnet_with_title() {
esac
done
set_terminal_title "${host}:${port}"
echo -ne "\033]2;${host}:${port}\033\\"
telnet "$@"
set_terminal_title
}
@@ -215,7 +232,7 @@ function ssh_with_title() {
esac
done
set_terminal_title "$host"
echo -ne "\033]2;${host}\033\\"
ssh "$@"
set_terminal_title
}