Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: Update mapset and simplify shell prompts #923

Merged
merged 1 commit into from
Aug 27, 2020

Conversation

wenzeslaus
Copy link
Member

  • Updates mapset also for bash (already done for tcsh and zsh).
  • Removes GRASS GIS version from the prompt (already in the welcome text).
  • Removes w/W from PS1 in the default/fallback shell setup (not supported by POSIX or sh).
  • Removes location (name) from PS1 in the default/fallback shell setup (making no assumptions on what is supported).
  • Uses W instead of w (i.e., current directory name, not path) for Bash to make the prompt shorter.
  • Adds /mapset (name) after the location (name) for Bash and removes quotes around it (saves two characters, possibly less cluttered).
  • Remove obsolete and outdated LOCATION variable defined in shell (MAPSET_PATH already available as a replacement).
  • Make prompts more similar to each other.

* Updates mapset also for bash (already done for tcsh and zsh).
* Removes GRASS GIS version from the prompt (already in the welcome text).
* Removes w/W from PS1 in the default/fallback shell setup (not supported by POSIX or sh).
* Removes location (name) from PS1 in the default/fallback shell setup (making no assumptions on what is supported).
* Uses W instead of w (i.e., current directory name, not path) for Bash to make the prompt shorter.
* Adds /mapset (name) after the location (name) for Bash and removes quotes around it (saves two characters, possibly less cluttered).
* Remove obsolete and outdated LOCATION variable defined in shell (MAPSET_PATH already available as a replacement).
* Make prompts more similar to each other.
@wenzeslaus
Copy link
Member Author

Here are the different prompts:

bash

GRASS nc_spm_08_grass7/landsat:grass >

zsh

GRASS : grass >                                                               Mapset <landsat> in <nc_spm_08_grass7>

tcsh

Mapset <landsat> in Location <nc_spm_08_grass7>
GRASS > 

sh (fallback)

GRASS > 

Feel free to suggest changes. For example, I actually prefer to see full path, not just current directory name, but I think it is a good trade-off to have more space for location/mapset and the actual command.

I focused on updating Bash now and just keeping the rest in sync. @nilason recently updated tcsh and added zsh. I think generally the prompts should be in sync in regard to e.g. showing the version number, but they can differ based on shell capabilities or common practices user of a given shell are used to.

@wenzeslaus
Copy link
Member Author

Here are different interactive shells with their welcome messages and prompts. (The welcome messages are just for context. This PR is only changing prompts.)

bash on Ubuntu

joedoe@unix:~/Documents$

zsh default

unix%

tcsh on Ubuntu

unix:~/Documents> 

python

Python 3.8.2 (default, Jul 16 2020, 14:00:26) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

ipython

Python 3.8.2 (default, Jul 16 2020, 14:00:26) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]:  

pipenv shell with Bash on Ubuntu

Launching subshell in virtual environment…
 . /home/joedoe/.local/share/virtualenvs/myproject-0M5-HDhf/bin/activate
joedoe@unix:~/Documents/myproject$  . /home/joedoe/.local/share/virtualenvs/myproject-0M5-HDhf/bin/activate
(myproject) joedoe@unix:~/Documents/myproject$

R

R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 

octave

GNU Octave, version 5.2.0
Copyright (C) 2020 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> 

nodejs

> 

irb (Interactive Ruby)

irb(main):001:0> 

@veroandreo
Copy link
Contributor

Tested and solves #921. I like the prompt changes, too 👍

@neteler
Copy link
Member

neteler commented Aug 22, 2020

I'd suggest to put colors:

grass79_bash_prompt

@wenzeslaus
Copy link
Member Author

I'd suggest to put colors

I like that, but let's leave modernization with colors and unicode (:ear_of_rice: :seedling: ?) to another PR.

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are good and reasonable changes. I was considering dropping version from prompt with the addition of zsh, but left it as was at that time. It only takes up space. With the addition of mapset to bash, current directory only (as opposed to full path) is a good trade-off. Not difficult to pwd if one got lost.

Successfully tested with both bash and zsh.

@wenzeslaus wenzeslaus merged commit a96204b into OSGeo:master Aug 27, 2020
@wenzeslaus
Copy link
Member Author

@nilason Awesome, thanks. Yes, it is a trade-off.

@neteler You put yourself on a review, but I proceeded without it. Please, open a new issue for any bugs or wishes.

@wenzeslaus wenzeslaus added this to In progress in Shells via automation Sep 12, 2020
@wenzeslaus wenzeslaus moved this from In progress to Done in Shells Sep 12, 2020
@neteler neteler added this to the 8.0.0 milestone Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Shells
  
Done
Development

Successfully merging this pull request may close these issues.

[Bug] Location change from Data tab in the GUI not reflected in the terminal prompt
4 participants