#11790: `sage --sh -c ...` shouldn't print [that many] messages
------------------------------+---------------------------------------------
Reporter: leif | Owner:
Type: defect | Status: needs_work
Priority: minor | Milestone: sage-4.7.2
Component: scripts | Keywords: subshell commands sage-sage
environment batch mode stdout
Work_issues: | Upstream: N/A
Reviewer: Jeroen Demeyer | Author: John Palmieri
Merged: | Dependencies: #11866
------------------------------+---------------------------------------------
Comment(by jhpalmieri):
I wouldn't mind shortening the prompt to one line, but I'd like to get
more feedback, so I asked the question on sage-devel.
If it is shortened, should we do more to highlight that we're in a
subshell? The following shortens "(sage subshell)" to "(Sage)" and puts
in reverse video. We could use boldface if reverse video is too
obnoxious.
{{{
#!diff
diff --git a/sage-sage b/sage-sage
--- a/sage-sage
+++ b/sage-sage
@@ -490,10 +491,19 @@ if [ "$1" = '-sh' -o "$1" = '--sh' ]; t
# We must start a new shell with no .profile or .bashrc files
# processed, so that we know our path is correct
SHELL_NAME=`basename "$SHELL"`
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
case "$SHELL_NAME" in
bash)
SHELL_OPTS=" --norc"
- PS1="SAGE_ROOT=${SAGE_ROOT}\n(sage subshell) \h:\W \u\$ "
+ if [ "$color_prompt" = yes ] ; then
+ PS1="\[$(tput rev)\](Sage)\[$(tput sgr0)\] \h:\W \u\$ "
+ else
+ PS1="(Sage) \h:\W \u\$ "
+ fi
export PS1
;;
csh)
@@ -504,14 +514,18 @@ if [ "$1" = '-sh' -o "$1" = '--sh' ]; t
;;
ksh)
SHELL_OPTS=" -p"
- PS1="SAGE_ROOT=${SAGE_ROOT}
-(sage subshell) `hostname -s`:\${PWD##*/} $USER$ "
+ if [ "$color_prompt" = yes ] ; then
+ PS1="\[$(tput rev)\](Sage)\[$(tput sgr0)\] `hostname
-s`:\${PWD##*/} $USER$ "
+ else
+ PS1="(Sage) `hostname -s`:\${PWD##*/} $USER$ "
+ fi
export PS1
;;
sh)
- SHELL_OPTS=" --norc"
- PS1="SAGE_ROOT=${SAGE_ROOT}
-(sage subshell) `hostname -s`:\${PWD##*/} $USER$ "
+ # If sh is derived from bash, then the following is okay,
+ # but we shouldn't assume this.
+ #SHELL_OPTS=" --norc"
+ PS1="(Sage) `hostname -s`:\${PWD##*/} $USER$ "
export PS1
;;
tcsh)
@@ -521,8 +535,11 @@ if [ "$1" = '-sh' -o "$1" = '--sh' ]; t
SHELL_OPTS=" -f"
;;
zsh)
}}}
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11790#comment:15>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.