Set terminal window/tab title to pwd/command
This commit is contained in:
6
.rc
6
.rc
@@ -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
26
.zshrc
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user