I've been defining some functions in .bashrc
, and now the start-up time isn't great.
I've tried a quick solution - to move the function definitions to .bash_profile
, and export them, so they only get read once when I login. This makes sense, since these functions never change.
This works for tty logins, but not for the graphical environment. My system is Ubuntu 12.10. I've googled that for the graphical session, the equivalent to .bash_profile
is .profile
. The problem is that it's not equivalent:
export -f my_function
will work for .bash_profile
, but not for .profile
, because .profile
is read by /bin/sh
and not /bin/bash
.
So the last step to solve my problem would be one of:
~/.profile-that-is-read-by-bash
/bin/bash
read ~/.profile
Any ideas on this?
The tty
GUI sessions are probably not login shells, only interactive login shells read ~/.bash_profile or ~/.profile. Bash reads ~/.profile (by default) only if ~/.bash_profile does not exist.
Exporting functions might be the overhead. Do you really need all those functions every time? Why not put them into some other file and source
them when needed?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.