.bashrc used in gnome not just terminal

1

I've recently started using the Anaconda Python distribution for software development and I want it to be the default Python distribution when I run something in the terminal. In order to do this, I've added the Anaconda binaries directory to my .bashrc file:

export PATH="/opt/anaconda:$PATH"

This works fine.

However, now certain tools don't work in my Gnome desktop environment. I can't run gnome-tweak-tool and I can't open a terminal using a keyboard shortcut I assigned.

I've tracked down this problem to the fact that these operations now use my Anaconda installation and not the original, which has some extra libraries installed (e.g. `gi').

So how do I fix this problem? Is there any way to have things executed only at the start of a terminal session and not for my entire gnome environment?

Mark

Posted 2014-06-27T09:00:13.143

Reputation: 11

Answers

1

One way to do it would be to alias the python command to use anaconda rather than changing your path. Instead of changing your path, try adding:

alias python="/opt/anaconda"

to your .bashrc file. This should make it so anaconda will only be run when you type "python" into the terminal, not when something else tries to use it. (somebody correct me if I'm wrong, but this should work)

Tyler Olsen

Posted 2014-06-27T09:00:13.143

Reputation: 111

0

The word you are looking for here is interactive shell, which reads input from a user and displays the output in a terminal. This is in contrast to non-interactive shells that run commands from a script without any user input (programs, scripts or desktop environments run the shell non-interactively).

In your .bashrc you can easily test if the shell is interactive (in bash it has $- set to i; you can also test if $PS1 is defined) and then execute your command only in interactive shells:

if [[ $- == *i* ]] # Test if the shell is interactive
then
    echo "Welcome in the interactive shell"
    export PATH="/opt/anaconda:$PATH"
fi

Programs and environments such as the Gnome will ignore the lines above, because they run bash non-interactively.

Calimo

Posted 2014-06-27T09:00:13.143

Reputation: 1 119