[vte/vte-0-34] bash: Add /etc/profile.d/vte.sh script
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-34] bash: Add /etc/profile.d/vte.sh script
- Date: Tue, 5 Jun 2012 13:07:55 +0000 (UTC)
commit 2975562afc96125911e1d4635382a87c90b97ff0
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 875f36c..9265f6e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -334,7 +334,10 @@ 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
-include $(INTROSPECTION_MAKEFILE)
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]