From c5a98cc0e2d8c030acc7d6f510886a957b78fc68 Mon Sep 17 00:00:00 2001 From: Luca Bilke Date: Wed, 14 Jun 2023 22:12:51 +0200 Subject: [PATCH] better titlestrings --- .config/lf/clean | 3 --- .config/lf/lfrc | 6 +++--- .config/zsh/.zshrc | 20 +++++++++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) delete mode 100755 .config/lf/clean diff --git a/.config/lf/clean b/.config/lf/clean deleted file mode 100755 index 91a9aa5..0000000 --- a/.config/lf/clean +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -kitty +kitten icat --clear --transfer-mode file - diff --git a/.config/lf/lfrc b/.config/lf/lfrc index 456a601..602a08d 100644 --- a/.config/lf/lfrc +++ b/.config/lf/lfrc @@ -9,7 +9,6 @@ set wrapscroll set period 1 set previewer ~/.config/lf/preview set cleaner ~/.config/lf/clean -set promptfmt "\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m%d\033[33m%f\033[35m]\033[0m" cmd open ${{ case $(file --mime-type "$(readlink -f $f)" -b) in @@ -95,8 +94,9 @@ cmd link %{{ cmd bulkrename $vidir cmd on-cd &{{ - DIR=$(echo $PWD | sed "s|$HOME|~|") - printf "\033]0; $DIR\007" > /dev/tty + printf "%b" "\033]0;$(zsh -c 'source $XDG_CONFIG_HOME/zsh/configs/autogenerated/hashes; print -Pn "$USER@$HOST [%3~]"') \007" > /dev/tty + fmt="\033[34;1m%u\033[36m@\033[34m%h \033[35m[\033[0;1m$(zsh -c 'source $XDG_CONFIG_HOME/zsh/configs/autogenerated/hashes; print -Pn "%3~"')\033[35m]\033[32m » \033[33m%f\033[0m" + lf -remote "send $id set promptfmt \"$fmt\"" }} on-cd diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index e3758a6..2135389 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -52,8 +52,18 @@ zle -N zle-line-init echo -ne '\e[5 q' # Use beam shape cursor on startup. preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. +# Set the titlestring +function write_title_cmd() { + if [ ${1[(w)1]} != "lfwrap" ]; then + echo -ne "\033]0;$(print -P "%n@%m [%3~] » ${1[(w)1]}")\007" + fi +} +add-zsh-hook preexec write_title_cmd +function write_title_wd() { echo -ne "\033]0;$(print -P "%n@%m [%3~]")\007" } +add-zsh-hook precmd write_title_wd + # Use lf to switch directories and bind it to ctrl-o -lfcd () { +lfwrap () { tmp="$(mktemp)" fid="$(mktemp)" lf -command '$printf $id > '"$fid"'' -last-dir-path="$tmp" "$@" @@ -75,12 +85,12 @@ lfcd () { tput cuu1;tput el } -_lfcd () { - BUFFER="lfcd" +_lf () { + BUFFER="lfwrap" zle accept-line } -zle -N _lfcd -bindkey '^e' _lfcd +zle -N _lf +bindkey '^e' _lf # bind lazygit to ctrl-g lg () {