Set terminal window/tab title to pwd/command

This commit is contained in:
2013-10-29 13:08:08 +03:00
parent b7256c1416
commit ecd871d130
2 changed files with 27 additions and 5 deletions

6
.rc
View File

@@ -56,7 +56,7 @@ alias fsck='fsck -C'
alias pager=$PAGER
alias npager='pager -N'
alias l='ls -lA'
alias ll='ls -l'
alias ll='ls -la'
alias la='cat /proc/loadavg'
alias ipt='iptables -nvL --line-numbers'
alias psa='ps axfo pid,euser,bsdstart,vsz,rss,bsdtime,args'
@@ -174,10 +174,6 @@ function fin() {
find "$@" -iname "*$filename*"
}
function title() {
echo -ne "\033]0;$*\007"
}
function tt() {
tail -f "$@" | while read line; do echo -n $(date); echo -e "\t$line"; done
}

26
.zshrc
View File

@@ -59,4 +59,30 @@ autoload -U promptinit
promptinit
prompt clint
# title <tab_title> <window_title>
function title() {
[ "$DISABLE_AUTO_TITLE" != "true" ] || return
if [[ "$TERM" == screen* ]]; then
print -Pn "\ek$1:q\e\\"
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
# Window title
[ -n "$2" ] && print -Pn "\e]2;$2:q\a"
# Tab title (gnome-terminal, konsole)
print -Pn "\e]1;$1:q\a"
fi
}
function terminal_title_at_prompt {
# "pwd" in tab, "user@host: pwd" in window
title "%15<..<%~%<<" "%n@%m: %~"
}
function terminal_title_on_command {
title "$1" "$1"
}
autoload -U add-zsh-hook
add-zsh-hook precmd terminal_title_at_prompt
add-zsh-hook preexec terminal_title_on_command
source ~/.rc