Overriding default browser

408 views
Skip to first unread message

Jim Clark

unread,
Mar 5, 2012, 11:40:48 AM3/5/12
to sage-s...@googlegroups.com
I am running Sage 4.8 on Mac OS X 10.6.8.

I have been using Safari as my default browser, but I am getting discouraged because Safari crashes frequently.

All of my bookmarks and ways of browsing the web are in Safari, so I want to keep Safari as my default browser,
but I am switching to Firefox when using Sage.

I can override the default browser by putting export SAGE_BROWSER="firefox"

in the file .bashrc in my home directory. This I have done. It has no effect. When I issue the command notebook() at the sage: prompt, the notebook still starts up in Safari. I have to kill Safari and then start Firefox manually (where I have set my home page to be http://localhost:8000).

It's annoying. Is there any way to get this documented feature to work as advertised?

Thank you,
Jim Clark

John H Palmieri

unread,
Mar 5, 2012, 11:52:18 AM3/5/12
to sage-s...@googlegroups.com


On Monday, March 5, 2012 8:40:48 AM UTC-8, Jim wrote:
I am running Sage 4.8 on Mac OS X 10.6.8.

I have been using Safari as my default browser, but I am getting discouraged because Safari crashes frequently.

All of my bookmarks and ways of browsing the web are in Safari, so I want to keep Safari as my default browser,
but I am switching to Firefox when using Sage.

I can override the default browser by putting export SAGE_BROWSER="firefox"

When I do this and then start the notebook, I see

  .../local/bin/sage-native-execute: line 8: firefox: command not found

This works for me:

  export SAGE_BROWSER='open -a /Applications/Firefox.app'

(Change this to the path to the firefox app, if necessary.) The documentation apparently needs to be fixed, at least as far as OS X is concerned.

--
John

John H Palmieri

unread,
Mar 5, 2012, 11:57:56 AM3/5/12
to sage-s...@googlegroups.com

Oh, a few more things, in case people are reading this who aren't that familiar with the Terminal app and bash: you can give the command


  export SAGE_BROWSER='open -a /Applications/Firefox.app'

at the shell prompt and it will have immediate effect, so you can test it right away.  Second, if you instead change .bashrc, you should start a new terminal window for the changes to take effect. You can test whether it has done anything by typing 'export' and seeing if SAGE_BROWSER is listed with the appropriate setting.

--
John

Jim Clark

unread,
Mar 5, 2012, 12:38:01 PM3/5/12
to sage-s...@googlegroups.com
On Mar 5, 2012, at 8:57 AM, John H Palmieri wrote:

This works for me:

  export SAGE_BROWSER='open -a /Applications/Firefox.app'

(Change this to the path to the firefox app, if necessary.) The documentation apparently needs to be fixed, at least as far as OS X is concerned.

Oh, a few more things, in case people are reading this who aren't that familiar with the Terminal app and bash: you can give the command

  export SAGE_BROWSER='open -a /Applications/Firefox.app'

at the shell prompt and it will have immediate effect, so you can test it right away.  Second, if you instead change .bashrc, you should start a new terminal window for the changes to take effect. You can test whether it has done anything by typing 'export' and seeing if SAGE_BROWSER is listed with the appropriate setting.

Thanks for your help, John.

It turned out to be more complicated, trying to understand the deep mysteries of the bash shell and how Terminal is configured on my system. In spite of what the man page for bash says, Terminal seems to be ignoring the .bashrc file in my home directory, and instead reads .bash_profile. I was finally able to get Sage and notebook() to start Firefox by putting the export SAGE_BROWSER line into .bash_profile, not .bashrc.

This has taken much more time than I hoped for, but at least my problem is now solved.

Jim

Justin C. Walker

unread,
Mar 5, 2012, 3:49:48 PM3/5/12
to sage-s...@googlegroups.com

To clarify this, I believe that the man page says that .bash_profile is checked for a login shell, and that .bashrc is checked for a non-login, interactive shell.

I'm not at a 10.6 system right now to verify that, but it is the case on 10.7, and I have my "profile/rc" set up with that assumption on both 10.6 and 10.7.

Justin

--
Justin C. Walker, Curmudgeon at Large
Director
Institute for the Enhancement of the Director's Income
-----------
Nobody knows the trouble I've been
-----------

Jim Clark

unread,
Mar 5, 2012, 4:09:04 PM3/5/12
to sage-s...@googlegroups.com
On Mar 5, 2012, at 12:49 PM, Justin C. Walker wrote:

> To clarify this, I believe that the man page says that .bash_profile is checked for a login shell, and that .bashrc is checked for a non-login, interactive shell.
>
> I'm not at a 10.6 system right now to verify that, but it is the case on 10.7, and I have my "profile/rc" set up with that assumption on both 10.6 and 10.7.

Thanks, Mr. Curmudgeon ;-)

That is indeed what I read in the man page, but my intuitive sense is that Terminal should open a "non-login, interactive shell" — after all, I am able to start entering UNIX commands interactively, and the shell does not prompt for a login. But when I actually try it out, the contents of .bashrc have no effect in Terminal/bash, but the contents of .bash_profile are processed. I conclude that something about a deeper understanding of Mac OS X and/or UNIX is eluding me.

Jim

Justin C. Walker

unread,
Mar 5, 2012, 5:06:08 PM3/5/12
to sage-s...@googlegroups.com

I think your confusion is in the use of the term "login".

Terminal starts a login shell for each window/tab that it opens, so your intuition needs a little polishing :-} Think of Terminal as a glorified xterm, in that all the windows belong to one Terminal, rather than each xterm owning one window.

Login shells are represented (e.g., in 'ps' listings) with a leading "-" in the command name; and if you check a full "ps" listing, you'll see that the "parent" shell in each window (i.e., for each (pseudo)tty) has such a tag, and typically, no others do.

HTH

Justin

--
Justin C. Walker
Curmudgeon-at-large
--
Network, n., Difference between work
charged for and work done

Jim Clark

unread,
Mar 5, 2012, 5:15:33 PM3/5/12
to sage-s...@googlegroups.com
On Mar 5, 2012, at 2:06 PM, Justin C. Walker wrote:

> Terminal starts a login shell for each window/tab that it opens, so your intuition needs a little polishing :-} Think of Terminal as a glorified xterm, in that all the windows belong to one Terminal, rather than each xterm owning one window.

Thanks, Justin, for helping with the polishing. I'm learning more about Terminal than I ever wanted to know — I just want to get on with using Sage to solve the problem I'm working on.
Jim

Reply all
Reply to author
Forward
0 new messages