]> git.donarmstrong.com Git - zsh.git/commitdiff
migrate xterm-title setting to zshrc
authormartin f. krafft <madduck@madduck.net>
Mon, 5 May 2008 20:54:50 +0000 (21:54 +0100)
committermartin f. krafft <madduck@madduck.net>
Mon, 5 May 2008 20:54:50 +0000 (21:54 +0100)
.zsh/xterm-title [deleted file]
.zsh/zshrc/00_TODO
.zsh/zshrc/90_xterm_title [new file with mode: 0644]

diff --git a/.zsh/xterm-title b/.zsh/xterm-title
deleted file mode 100644 (file)
index 631c651..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-# zterm-title
-#
-# Fancy setting of the xterm title
-#
-# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
-# Released under the terms of the Artistic Licence 2.0
-#
-# Source repository: http://git.madduck.net/v/etc/zsh.git
-#
-# Based on http://www.zshwiki.org/cgi-bin/wiki.pl?ZshHardStatus
-#
-
-__set_xterm_title() {
-  case $TERM in
-    screen)
-      print -nR $'\033k'$1$'\033'\\ 
-      print -nR $'\033]0;'$2$'\a'
-      ;;
-    xterm|rxvt*)
-      print -nR $'\033]0;'$*$'\a'
-      ;;
-  esac
-}
-
-__get_session_flags() {
-  [ -n "$SSH_CONNECTION" ] || return
-  local flags; flags=
-  [ -n "$DISPLAY" ] && flags="${flags}x"
-  [ -n "$SSH_AUTH_SOCK" ] && flags="${flags}a"
-  [ -n "$flags" ] && echo "[${flags}]"
-}
-
-__get_standard_prompt() {
-  print -P "%m%# %25\<..\<%~ $(__get_session_flags)"
-}
-
-set_plain_xterm_title() {
-  __set_xterm_title "$(__get_standard_prompt)"
-}
-
-set_cmd_xterm_title () {
-    local -a cmd; cmd=(${(z)1})             # Re-parse the command line
-
-    # Construct a command that will output the desired job number.
-    case $cmd[1] in
-        fg) if (( $#cmd == 1 )); then
-                # No arguments, must find the current job
-                cmd=(builtin jobs -l %+)
-            else
-                # Replace the command name, ignore extra args.
-                cmd=(builtin jobs -l ${(Q)cmd[2]})
-            fi;;
-        %*) cmd=(builtin jobs -l ${(Q)cmd[1]});; # Same as "else" above
-        *) # Not resuming a job,
-            __set_xterm_title $cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
-            return;;                        # so we're all done
-    esac
-
-    local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell
-
-    # Run the command, read its output, and look up the jobtext.
-    # Could parse $rest here, but $jobtexts (via $jt) is easier.
-    $cmd >>(
-              read num rest
-              cmd=(${(z)${(e):-\$jt$num}})
-              __set_xterm_title $leader$cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
-           )
-}
-
-# vim:ft=zsh
index 902c9ea377f567783b82e10ee6e6e88071fcde39..2a6d13b67a85e1ece68f6d78c1663903a6e5d13e 100644 (file)
@@ -31,11 +31,6 @@ typeset -ga preexec_functions
 typeset -ga precmd_functions
 typeset -ga chpwd_functions
 
-. $ZDOTDIR/xterm-title
-
-precmd_functions+=set_plain_xterm_title
-preexec_functions+=set_cmd_xterm_title
-
 [ "$(umask)" = 022 ] && umask 0077
 
 eval `lesspipe 2>/dev/null`
diff --git a/.zsh/zshrc/90_xterm_title b/.zsh/zshrc/90_xterm_title
new file mode 100644 (file)
index 0000000..e700aa1
--- /dev/null
@@ -0,0 +1,72 @@
+# zterm-title
+#
+# Fancy setting of the xterm title
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+# Based on http://www.zshwiki.org/cgi-bin/wiki.pl?ZshHardStatus
+#
+
+__set_xterm_title() {
+  case $TERM in
+    screen)
+      print -nR $'\033k'$1$'\033'\\ 
+      print -nR $'\033]0;'$2$'\a'
+      ;;
+    xterm|rxvt*)
+      print -nR $'\033]0;'$*$'\a'
+      ;;
+  esac
+}
+
+__get_session_flags() {
+  [ -n "$SSH_CONNECTION" ] || return
+  local flags; flags=
+  [ -n "$DISPLAY" ] && flags="${flags}x"
+  [ -n "$SSH_AUTH_SOCK" ] && flags="${flags}a"
+  [ -n "$flags" ] && echo "[${flags}]"
+}
+
+__get_standard_prompt() {
+  print -P "%m%#%25\<..\<%~ $(__get_session_flags)"
+}
+
+_set_plain_xterm_title() {
+  __set_xterm_title "$(__get_standard_prompt)"
+}
+precmd_functions+=_set_plain_xterm_title
+
+_set_cmd_xterm_title () {
+    local -a cmd; cmd=(${(z)1})             # Re-parse the command line
+
+    # Construct a command that will output the desired job number.
+    case $cmd[1] in
+        fg) if (( $#cmd == 1 )); then
+                # No arguments, must find the current job
+                cmd=(builtin jobs -l %+)
+            else
+                # Replace the command name, ignore extra args.
+                cmd=(builtin jobs -l ${(Q)cmd[2]})
+            fi;;
+        %*) cmd=(builtin jobs -l ${(Q)cmd[1]});; # Same as "else" above
+        *) # Not resuming a job,
+            __set_xterm_title $cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
+            return;;                        # so we're all done
+    esac
+
+    local -A jt; jt=(${(kv)jobtexts})       # Copy jobtexts for subshell
+
+    # Run the command, read its output, and look up the jobtext.
+    # Could parse $rest here, but $jobtexts (via $jt) is easier.
+    $cmd >>(
+              read num rest
+              cmd=(${(z)${(e):-\$jt$num}})
+              __set_xterm_title $leader$cmd[1]:t${cmd[2]:+ }$cmd[2,-1] "| $(__get_standard_prompt)"
+           )
+}
+preexec_functions+=_set_cmd_xterm_title
+
+# vim:ft=zsh