How to execute a function in the .profile file

I have a function which is intended to remove replicate copies of directory sites from my PATH setting variable. I have actually developed some matches so I can examine it yet I do not recognize just how to:

1) place the manuscript in the $HOME/.bashrc documents

2
2022-06-07 14:39:46
Source Share
Answers: 2

Just modify the .bashrc documents (far better make a duplicate of the initial first, simply in instance) and also merely add a line the name of the manuscript you intend to execute to the documents (at the end of the .bashrc would certainly be great).

If the manuscript is not in your house directory, make certain to define the full course.

1
2022-06-07 15:11:00
Source

The right apply for setting variables such as PATH is not ~/.bashrc yet ~/.profile. .bashrc is an arrangement apply for interactive coverings ; .profile is the session start-up manuscript. See Is there a ".bashrc" equivalent file read by all shells?.

Bash is a little bit strange with its start-up files: in login coverings, it reviews ~/.bash_profile if it exists and also ~/.profile or else. In interactive non - login coverings, it reviews ~/.bashrc. There is no factor not to load interactive setups in interactive login coverings, and also there are several arrangements where the session start covering is not conjured up as a login covering yet ~/.profile reads clearly. So make your ~/.bash_profile have simply these 2 lines:

. ~/.profile
case $- in *i*) . ~/.bashrc;; esac

If you had points in ~/.bash_profile, relocate them to ~/.profile if they are points like setting variable setups, and also to ~/.bashrc if they are interactive covering arrangement such as pen names and also key bindings. Place all your PATH adjustment in ~/.profile.

0
2022-06-07 14:48:01
Source