[GRASS-SVN] r60216 - grass/trunk/lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 12 21:15:54 PDT 2014
Author: hcho
Date: 2014-05-12 21:15:54 -0700 (Mon, 12 May 2014)
New Revision: 60216
Removed:
grass/trunk/lib/init/prompt.py
Modified:
grass/trunk/lib/init/grass.py
Log:
Replaced prompt.py with a bash function for bash startup.
Fixed ticket #2284.
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2014-05-13 03:28:43 UTC (rev 60215)
+++ grass/trunk/lib/init/grass.py 2014-05-13 04:15:54 UTC (rev 60216)
@@ -1113,8 +1113,17 @@
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 [Raster and Volume MASKs present]
+ elif test -f "$LOCATION/cell/MASK" ; then
+ echo [Raster MASK present]
+ elif test -d "$LOCATION/grid3/G3D_MASK" ; then
+ echo [Volume MASK present]
+ fi
+}
+PROMPT_COMMAND=grass_prompt\n""")
# read environmental variables
path = os.path.join(userhome, ".grass.bashrc") # left for backward compatibility
Deleted: grass/trunk/lib/init/prompt.py
===================================================================
--- grass/trunk/lib/init/prompt.py 2014-05-13 03:28:43 UTC (rev 60215)
+++ grass/trunk/lib/init/prompt.py 2014-05-13 04:15:54 UTC (rev 60216)
@@ -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())
More information about the grass-commit
mailing list