aboutsummaryrefslogtreecommitdiffstats
path: root/_zsh/40-hooks.zsh
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2017-03-19 12:46:30 +0800
committerAaron LI <aaronly.me@outlook.com>2017-03-19 12:46:30 +0800
commit2cc4962be6a65ce3d34197084216318e404cc2a9 (patch)
tree0e406f5ddb804e557a429dfbd4896170059ef266 /_zsh/40-hooks.zsh
parent9fee8ed6e79decd9481cde6540e1575b3ba1e9ed (diff)
downloaddotfiles-2cc4962be6a65ce3d34197084216318e404cc2a9.tar.bz2
zsh: Move precmd() and preexec() to hooks.zsh
Diffstat (limited to '_zsh/40-hooks.zsh')
-rw-r--r--_zsh/40-hooks.zsh39
1 files changed, 12 insertions, 27 deletions
diff --git a/_zsh/40-hooks.zsh b/_zsh/40-hooks.zsh
index defee0b..da15a29 100644
--- a/_zsh/40-hooks.zsh
+++ b/_zsh/40-hooks.zsh
@@ -1,34 +1,19 @@
#
# zsh/hooks.zsh
#
-
-# Put the string "hostname::/full/directory/path" in the title bar:
-function set_term_title {
- echo -ne "\e]2;$PWD\a"
-}
-
-# Put the parentdir/currentdir in the tab
-function set_term_tab {
- echo -ne "\e]1;$PWD:h:t/$PWD:t\a"
-}
-
-function precmd {
- set_term_title
- set_term_tab
-}
-
-
-#function set_running_app {
-# printf "\e]1; $PWD:t:$(history $HISTCMD | cut -b7- ) \a"
-#}
-#
-#function preexec {
-# set_running_app
-#}
+# Credit: http://chneukirchen.org/dotfiles/.zshrc
#
-#function postexec {
-# set_running_app
-#}
+
+case "$TERM" in
+xterm*|rxvt*)
+ function precmd() {
+ [[ -t 1 ]] && print -Pn "\e]0;%m: %~\a"
+ }
+ function preexec() {
+ [[ -t 1 ]] && print -n "\e]0;$HOST: ${(q)1//(#m)[$'\000-\037\177-']/${(q)MATCH}}\a"
+ }
+ ;;
+esac
# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=zsh: #