# How to call certain file whenever one is in the ROOT environment in terminal?

**URL:** <https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025>\
**Category:** ROOT\
**Tags:** root\
**Created:** [October 26, 2024, 1:06am UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025 "2024-10-26T01:06:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divyang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/7ea924/32.png) [@Divyang](https://root-forum.cern.ch/u/Divyang)\
**Post date:** [October 26, 2024, 1:06am UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025/1 "2024-10-26T01:06:53Z")

</div>

Hello ROOTers,

I want to execute certain C++ code whenever I enter into the ROOT environment from the terminal. For example, the welcome message is printed all the time as shown here

```auto
d@d:~$ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.24/08 https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Sep 29 2022, 13:04:57 |
  | From tags/v6-24-08@v6-24-08 |
  | With |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] 

```

Similarly, I want to execute, let’s say

```auto
std::cout << "Hello from ROOT env!!!" << std::endl;

```

Is it possible? This will save a lot of time similar to VS Code Snippets.

Best,  
Divyang.

ROOT Version: 6.24/08  
Platform: Ubuntu 20.04.6  
Compiler: g++ 9.4.0

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [October 26, 2024, 5:51am UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025/2 "2024-10-26T05:51:52Z")

</div>

[https://root.cern/doc/master/rootlogon\_8C.html](https://root.cern/doc/master/rootlogon_8C.html)

---

<div class="post-metadata">

**Author:** ![Divyang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/7ea924/32.png) [@Divyang](https://root-forum.cern.ch/u/Divyang)\
**Post date:** [October 26, 2024, 10:59am UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025/3 "2024-10-26T10:59:21Z")

</div>

Hi, this solution worked. However, is it possible to call this file whenever I’m in the subdirectories of the main project directory? Otherwise, I have to keep this file in all the subdirectories.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 26, 2024, 11:09am UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025/4 "2024-10-26T11:09:37Z")

</div>

> [@rootlogon.C documentation](https://root-forum.cern.ch/t/rootlogon-c-documentation/49150/11):
>
> Well, to be precise, the order is as follows: “$(root-config --etcdir)/system.rootlogon.C” “${HOME}/.rootlogon.C” “${PWD}/.rootlogon.C” but only if “${PWD}” != “${HOME}” the file defined by “Rint.Logon” which exists in “TROOT::GetMacroPath()”, so, by default (see the “$(root-config --etcdir)/system.rootrc” file), it will be either “${PWD}/rootlogon.C” or “${ROOTSYS}/macros/rootlogon.C”

---

<div class="post-metadata">

**Author:** ![Divyang](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/7ea924/32.png) [@Divyang](https://root-forum.cern.ch/u/Divyang)\
**Post date:** [October 26, 2024, 4:44pm UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025/5 "2024-10-26T16:44:55Z")

</div>

FYI

I realized that rootalias.C is a better option compared to rootlogon.C. The reason is that the loading time for “root -l” is longer when rootlogon file is created in ${ROOTSYS}/macros.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 9, 2024, 4:45pm UTC](https://root-forum.cern.ch/t/how-to-call-certain-file-whenever-one-is-in-the-root-environment-in-terminal/62025/6 "2024-11-09T16:45:32Z")

</div>

Closed on November 9, 2024, 4:45pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
