Bläddra i källkod

Replaced prompt.py with a bash function for bash startup (backport from trunk, https://trac.osgeo.org/grass/changeset/60216 + https://trac.osgeo.org/grass/changeset/60222 + https://trac.osgeo.org/grass/changeset/60223) (trac https://trac.osgeo.org/grass/ticket/2284)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60735 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 11 år sedan
förälder
incheckning
8e7a1007c5
3 ändrade filer med 13 tillägg och 32 borttagningar
  1. 0 1
      lib/init/Makefile
  2. 13 2
      lib/init/grass.py
  3. 0 29
      lib/init/prompt.py

+ 0 - 1
lib/init/Makefile

@@ -25,7 +25,6 @@ FILES = \
 	$(ETC)/echo$(EXE) \
 	$(ETC)/license \
 	$(ETC)/VERSIONNUMBER \
-	$(ETC)/prompt.py \
 	$(HTMLDIR)/help_loc_struct.png \
 	$(HTMLDIR)/circle_1.png \
 	$(HTMLDIR)/circle_2.png \

+ 13 - 2
lib/init/grass.py

@@ -1097,8 +1097,19 @@ def bash_startup():
     else:
         f.write("PS1='GRASS %s (%s):\w > '\n" % (grass_version, location_name))
     
-    f.write("PROMPT_COMMAND=\"'%s'\"\n" % os.path.join(gisbase, 'etc',
-                                                       'prompt.py'))
+    f.write("""grass_prompt() {
+	LOCATION="`g.gisenv GISDBASE`/`g.gisenv LOCATION_NAME`/`g.gisenv MAPSET`"
+	if test -d "$LOCATION/grid3/G3D_MASK" && test -f "$LOCATION/cell/MASK" ; then
+		echo [%s]
+	elif test -f "$LOCATION/cell/MASK" ; then
+		echo [%s]
+	elif test -d "$LOCATION/grid3/G3D_MASK" ; then
+		echo [%s]
+	fi
+}
+PROMPT_COMMAND=grass_prompt\n""" % (_("2d and 3d Raster MASKs present"),
+                                    _("Raster MASK present"),
+                                    _("3d raster MASK present")))
 
     # read environmental variables
     path = os.path.join(userhome, ".grass.bashrc") # left for backward compatibility

+ 0 - 29
lib/init/prompt.py

@@ -1,29 +0,0 @@
-#!/usr/bin/env python
-
-import os
-import sys
-
-from grass.script import core as grass
-
-gisenv = grass.gisenv()
-
-import gettext
-gettext.install('grasslibs', os.path.join(gisenv['GISDBASE'], 'locale'), unicode = True)
-
-location = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'], gisenv['MAPSET'])
-
-has_mask   = os.path.isfile(os.path.join(location, 'cell', 'MASK'))
-has_mask3d = os.path.isdir(os.path.join(location, 'grid3', 'G3D_MASK'))
-
-def main():
-    if has_mask and has_mask3d:
-        grass.info(_("[Raster and Volume MASKs present]"))
-    elif has_mask:
-        grass.info(_("[Raster MASK present]"))
-    elif has_mask3d:
-        grass.info(_("[Volume MASK present]"))
-
-    return 0
-
-if __name__ == "__main__":
-    sys.exit(main())