Differences between revisions 12 and 18 (spanning 6 versions)
Revision 12 as of 2008-11-22 21:30:52
Size: 720
Editor: GreyCat
Comment: first-line
Revision 18 as of 2016-08-29 12:57:12
Size: 1077
Editor: GreyCat
Comment: Dear Linux people: not everyone is on Linux. Sincerely, the rest of the world.
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
== I want to launch an interactive shell that has a special set of aliases and functions, not the ones in the user's ~/.bashrc. == == I want to launch an interactive shell that has special aliases and functions, not the ones in the user's ~/.bashrc. ==
Line 9: Line 9:
Or:

{{{
bash --rcfile <(printf %s 'my; commands; here')
}}}

Or, if you happen to be on Linux:

{{{
 ~ $ bash --rcfile /dev/fd/3 -i 3<<<'cowsay moo'
 _____
< moo >
 -----
        \ ^__^
         \ (oo)\_______
            (__)\ )\/\
                ||----w |
                || ||
+bash-4.3$ exit
exit
}}}
Line 12: Line 34:

----
CategoryShell

I want to launch an interactive shell that has special aliases and functions, not the ones in the user's ~/.bashrc.

Just specify a different start-up file:

bash --rcfile /my/custom/bashrc

Or:

bash --rcfile <(printf %s 'my; commands; here')

Or, if you happen to be on Linux:

 ~ $ bash --rcfile /dev/fd/3 -i 3<<<'cowsay moo'
 _____
< moo >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
+bash-4.3$ exit
exit

Variant question: I have a script that sets up an environment, and I want to give the user control at the end of it.

Put exec bash at the end of it to launch an interactive shell. This shell will inherit the environment (which does not include aliases, but that's OK, because aliases suck). Of course, you must also make sure that your script runs in a terminal -- otherwise, you must create one, for example, by using exec xterm -e bash.


CategoryShell

BashFAQ/023 (last edited 2016-08-31 00:32:52 by ormaaj)