Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#1369 closed defect (wontfix)

setPrompt: command not found in GRASS7-svn

Reported by: moovida Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: Startup Version: svn-trunk
Keywords: shell, prompt Cc:
CPU: Unspecified Platform: Linux

Description (last modified by neteler)

The grass7 command shell doesn't appear to permit to have an own setPrompt.

I use a customized one to have some different information/coloring of the prompt in the case of git and hg repos:

function setPrompt(){
    thedate=`date "+%F %T"`
    if [ -d ./.git ]; then
        GITBRANCH="$NC($GREEN$(awk -F '/' '{ print $NF }' .git/HEAD)$NC"

        if [ $(git diff --exit-code > /dev/null 2>&1; echo $?) -eq 1 ] || [ $(git diff-index --cached --quiet --ignore-submodules HEAD --; echo $?) -eq 1 ]; then

        if [ "x$(git status | grep Untracked)" != "x" ]; then
        echo -e "\n${GREEN}GIT:${NC} ${GITBRANCH}"
        echo -e "${GREEN}======================================================  $thedate${NC}\n\n\w >>> "            
    elif [ -d ./.hg ]; then
        HGBRANCH="$NC($CYAN$(awk -F '/' '{ print $NF }' .hg/branch)$NC"

        if [ "x`hg status | grep ?`" != "x" ]; then
          HGBRANCH="$HGBRANCH [$RED+$NC])"
        echo -e "\n${CYAN}HG:${NC} ${HGBRANCH}"
        echo -e "${CYAN}======================================================  $thedate${NC}\n\n\w >>> "            
        echo -e "${RED}======================================================   $thedate${NC}\n\n\w >>> "            

which leads me to the error in the subject.

While for example in grass64 I have:

GRASS 6.4.0+42329 (gbovest):~ > echo $PROMPT_COMMAND 

in grass7 it seems to have changed to:


Change History (5)

comment:1 by martinl, 13 years ago

Milestone: 7.0.0

comment:2 by neteler, 13 years ago

Description: modified (diff)

comment:3 by wenzeslaus, 10 years ago

Resolution: wontfix
Status: newclosed



I think GRASS is not honoring the standard .bashrc in home by purpose if this is what are you trying to achieve. There are some discussion on mailing list about that.

[GRASS-SVN] r61051 - grass/trunk/lib/init

[GRASS-dev] Bash aliases in GRASS

[GRASS-user] loss of bash aliases

I think you need to use ~/.grass7/bashrc. Citing from one of the discussions:

So we have $LOCATION/.bashrc, ~/.grass7/bashrc, and ~/.grass.bashrc. Do they all have different purposes and are they documented clearly somewhere? (Huidae)

.grass.bashrc is related to GRASS 6. GRASS 7 stores environmental variables in ~/.grass7/bashrc. The init script in GRASS 7 also reads .grass.bashrc for backward compatibility. (Martin)

I'm afraid that this is wontfix/invalid (feature, not a bug). Perhaps should be documented better. Feel free to suggest location and wording.

comment:4 by hamish, 10 years ago

Keywords: shell prompt added

for me this was working fine for me last time I had a MASK map set,


As such, I would suggest that this bug is already fixed, not wontfix.

the place the is set is in lib/init/ line ~1085. is also in lib/init/ in the source tree.

fwiw I doubt that has to be or should be a python script, and I think it only slows things down to have it as such. By definition the bash prompt is going to have a Bourne shell already present and already cached in memory, and launching a python process is much more expensive than a built in function().

ISTR some trouble with this last time I tried G7 from the cmd.exe line on Windows, it had trouble finding the right python interpreter? Would need to recheck if that is still the case. Rather that worry about fixing that I'd again suggest to just put it back to a shell script and avoid the headache.


comment:5 by hcho, 10 years ago

You have to define grass_prompt() in ~/.grass7/bashrc:

  # your code here
} has already been replaced by grass_prompt() in trunk because of #2284.

Note: See TracTickets for help on using tickets.