As part of an online course on Git, the tutor recommended that we add some commands at the end of the .bashrc file so that the terminal prompt displays some useful Git-related information. These changes are very useful for the Git course but I don't like them for general use.
The Gnome Terminal has the ability to create profiles and set per profile preferences.
Is it possible to configure Bash in such a way that the changes added to the .bashrc file are associated only with a single terminal profile? I would like the Git-related information displayed in one terminal profile but not the others.
In case it is pertinent, this is the code at the end of the .bashrc file:
# Enable tab completion
source ~/git-completion.bash
# colors!
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
reset="\[\033[0m\]"
# Change command prompt
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# '\u' adds the name of the current user to the prompt
# '\$(__git_ps1)' adds git-related stuff
# '\W' adds the name of the current directory
export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset"
~/.bashrc_git
that sources your regular rc file(s), plus all the git-specific stuff, and then set the gnome terminal profile's custom command to be/bin/bash --rcfile=~/.bashrc_git
env FOO=bar bash
and branch in.bashrc
based on the value$FOO
. Unfortunately the current directory of the previous tab is not preserved in these cases.giton
andgitoff
or whatever names you choose, rather than fiddle with the mouse. Moreover, this way you don't have to decide when you open a new terminal.~/.bashrc
create a new file called~/.bashgit
with said commands. After opening a terminal and doing your fit stuff type. .bashgit
(observe space between two.
. Use ctrl+shit+t for new terminal tab to get unadultered.bashrc
if you've already run the git mods./bin/bash --rcfile ~/.bashrc_git
works (without the =) which is close to what I was looking for. I must set the modified profile as the default profile or use File > New window/tab to open a new terminal using the modified profile - just changing the profile via the Terminal menu does not run the custom command unfortunately (which is what I would have liked). You could re-post your comment (corrected) as an answer and I will accept it.