[vte/vte-next] bash: Add /etc/profile.d/vte.sh script



commit 2aa265c5c597c3230a7af4261b07544fa62389bd
Author: Christian Persch <chpe gnome org>
Date:   Mon Jun 4 23:51:27 2012 +0200

    bash: Add /etc/profile.d/vte.sh script
    
    This script exports __vte_ps1 which when used in PS1 will keep the terminal
    updated about the current directory. Use like this in ~/.bashrc:
    
    export PS1='\[$(__vte_ps1)\]'$PS1
    
    The urlencoding code is taken from gnome-doc-tool.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=675987

 src/Makefile.am |    5 ++++-
 src/vte.sh      |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 3f8f149..1608e57 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -359,6 +359,9 @@ mev_SOURCES = mev.c
 ssfe_SOURCES = ssfe.c
 xticker_SOURCES = xticker.c
 
-#
+# Shell
+
+profiledir = $(sysconfdir)/profile.d
+dist_profile_DATA = vte.sh
 
 -include $(top_srcdir)/git.mk
diff --git a/src/vte.sh b/src/vte.sh
new file mode 100644
index 0000000..f744d48
--- /dev/null
+++ b/src/vte.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+# Copyright  2006 Shaun McCance <shaunm gnome org>
+#
+# 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+__vte_urlencode() (
+  # This is important to make sure string manipulation is handled
+  # byte-by-byte.
+  LANG=C
+  arg="$1"
+  i="0"
+  while [ "$i" -lt ${#arg} ]; do
+    c=${arg:$i:1}
+    if echo "$c" | grep -q '[a-zA-Z/:_\.\-]'; then
+      echo -n "$c"
+    else
+      echo -n "%"
+      printf "%X" "'$c'"
+    fi
+    i=$((i+1))
+  done
+)
+
+__vte_ps1() {
+  printf "\e]7;file://%s" $HOSTNAME
+  __vte_urlencode "$PWD"
+  printf "\a"
+}



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