From f2159c3b3f60652d13a50700b3719fde242cad92 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Sat, 19 Dec 2020 22:01:44 -0700 Subject: Add title support to zsh --- .config/zsh/.zshrc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to '.config/zsh/.zshrc') diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index a88765c..c6b6996 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -2,7 +2,7 @@ # PS1 colors and style. autoload -U colors && colors -PS1="%{$fg_bold[red]%}[%{$fg_bold[yellow]%}%n%{$fg_bold[green]%}@%{$fg_bold[blue]%}%M %{$fg_bold[magenta]%}%(5~|%-2~/.../%2~|%~)%{$fg_bold[red]%}]%{$fg_bold[cyan]%}$%{$reset_color%} " +PS1="%{$fg_bold[red]%}[%{$fg_bold[yellow]%}%n%{$fg_bold[green]%}@%{$fg_bold[blue]%}%M %{$fg_bold[magenta]%}%(5~|%-2~/.../%2~|%~)%{$fg_bold[red]%}]%{$fg_bold[cyan]%}%#%{$reset_color%} " # Set LS_COLORS via dircolors. [[ -f $HOME/.config/dircolors ]] && eval "$(dircolors $HOME/.config/dircolors)" @@ -25,5 +25,20 @@ compinit # Include hidden files in autocomplete. _comp_options+=(globdots) +# Dynamic window title for zsh. +case "$TERM" in (rxvt|rxvt-*|st|st-*|*xterm*|(dt|k|E)term|alacritty) + local term_title () { print -n "\e]0;${(j: :q)@}\a" } + precmd () { + local DIR="$(print -P '[%c]%#')" + term_title "$DIR" "zsh" + } + preexec () { + local DIR="$(print -P '[%c]%#')" + local CMD="${(j:\n:)${(f)1}}" + term_title "$DIR" "$CMD" + } + ;; +esac + # Add syntax highlighting. . /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -- cgit v1.2.3-54-g00ecf