[vte/vte-0-34] prompt: zsh compatibility



commit fa9171fc7b9ed0f46e26dec32e2755c1c48c4c70
Author: Christian Persch <chpe gnome org>
Date:   Sat May 4 21:06:58 2013 +0200

    prompt: zsh compatibility

 src/vte.sh |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/vte.sh b/src/vte.sh
index 95fe635..b7a4975 100644
--- a/src/vte.sh
+++ b/src/vte.sh
@@ -1,6 +1,6 @@
-#!/bin/sh
 # Copyright © 2006 Shaun McCance <shaunm gnome org>
 # Copyright © 2013 Peter De Wachter <pdewacht gmail com>
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
@@ -15,10 +15,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-# Not bash?
-[ -n "$BASH_VERSION" ] || return
+# Not bash or zsh?
+[ -n "$BASH_VERSION" -o -n "$ZSH_VERSION" ] || return
+
+# Not an interactive shell?
+[[ $- == *i* ]] || return
 
-# Not an interactive shell, or not running under vte?
+# Not running under vte?
 [ -n "$PS1" -a "${VTE:-0}" -ge 3405 ] || return
 
 __vte_urlencode() (
@@ -44,15 +47,16 @@ __vte_ps1() {
 }
 
 __vte_osc7 () {
-  printf "\033]7;file://%s%s\a" "$2" "$(__vte_urlencode "$1")"
+  printf "\033]7;file://%s%s\a" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
 }
 
 __vte_prompt_command() {
-  printf "\033]0;%s %s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}" "$(__vte_osc7 "${PWD}" 
"${HOSTNAME:-}")"
+  printf "\033]0;%s %s:%s\007%s" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}" "$(__vte_osc7)"
 }
 
 case "$TERM" in
   xterm*|vte*)
-    PROMPT_COMMAND="__vte_prompt_command" 
+    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command" 
+    [ -n "$ZSH_VERSION"  ] && chpwd_functions+=(__vte_osc7)
     ;;
 esac


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]