# \[Tip\] A better way to add neofetch to your .bashrc

**URL:** <https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116>\
**Category:** General system\
**Created:** [June 11, 2021, 3:12pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116 "2021-06-11T15:12:16Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 3:12pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/1 "2021-06-11T15:12:16Z")

</div>

For some reason, many people like to add `neofetch` to their `.bashrc` (or `.zshrc`, or whatever shell rc file they are using). It seems to be the obligatory part of “ricing” your Linux install.

In my opinion, `neofetch` is just bloated kitsch, but if you’re one of those people who like bloated kitsch, this post is for you, I hope you find it helpful. 🙂

The biggest problem I see with adding `neofetch` to your `.bashrc` is that it slows down the loading of your terminal emulator.

On my crappy laptop, it takes almost 3 seconds to launch `neofetch`. Do I want to wait that much time _every single time_ I launch my terminal emulator (which I do more times a day than I can be bothered to count)? On my slightly less crappy desktop, it takes about 0.3 seconds. It does not seem like a big deal to lose 0.3 seconds, but it makes running the terminal emulator unresponsive and annoying. It feels like using windoze. I want my terminal emulator to just pop into existence, the moment I press the keyboard shortcut for it, faster than I can blink. BTW, this is also the reason why I avoid things like `nvm` and `oh-my-zsh` like the plague…

There is an easy way to display `neofetch` output instantly when you launch your terminal emulator.

Instead of just having:

```nohighlight
neofetch

```

add this instead to your `.bashrc`:

```nohighlight
cat .nf 2> /dev/null
setsid neofetch >| .nf

```

The way it works is that it just displays the contents of a file named `.nf` (if that file does not exist, there is no error message, since `stderr` is redirected to `/dev/null`). Then it launches a non-interactive shell session in which the output of `neofetch` is redirected to a file `.nf`. This is the file that will be displayed the next time you launch your terminal emulator. This comes at no performance penalty, since it runs in background.

The downside is that you are getting an outdated `neofetch` output from the last time you ran your terminal emulator. But you are unlikely to ever notice this problem, since the output of `neofetch` is similar. The speed at which it displays is more than worth it, but if that bothers you, you could setup a cronjob to update that file periodically. That is an overkill, in my opinion.

Here is a screenshot of my `neofetch` just for fun:

![Screenshot_20210611_171107](https://forum.endeavouros.com/uploads/default/original/3X/1/7/170729871de1303d8c6e47bff93e9cdc899aae73.jpeg)

BTW, I use Zsh as my interactive shell, but `neofetch` displays it wrongly., since my user’s default shell is still Bash. I just launch Zsh from Konsole. Instead of detecting a shell in which it uns, `neofetch` just shows the default shell.

Why don’t I just `chsh` to Zsh? I like having Bash as the default shell in the TTY, where I don’t need all the fancy features of Zsh, and Bash is default on Arch anyway.

---

<div class="post-metadata">

**Author:** ![keybreak](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/keybreak/32/9257_2.png) [@keybreak](https://forum.endeavouros.com/u/keybreak)\
**Post date:** [June 11, 2021, 3:16pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/2 "2021-06-11T15:16:55Z")

</div>

That’s better 😉

```bash
setsid bloatkitch >| .bk

```

---

<div class="post-metadata">

**Author:** ![freebird54](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/freebird54/32/83106_2.png) [@freebird54](https://forum.endeavouros.com/u/freebird54)\
**Post date:** [June 11, 2021, 3:47pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/3 "2021-06-11T15:47:04Z")

</div>

I have a simpler methodology that also works fine - but I may be influenced by running on a quick desktop 😁

I have neofetch in _.bashrc-personal_, but as I run xfce (and thus _xfce4-terminal --drop-down_ with multiple tabs) - it only shows up the first time, and doesn’t slow anything at all in regular use.

Of course, one of the tabs can contain the previous run of neofetch without disturbing anything either! Just another route to the same destination…

---

<div class="post-metadata">

**Author:** ![anon31549144](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/5f9b8f/32.png) [@anon31549144](https://forum.endeavouros.com/u/anon31549144)\
**Post date:** [June 11, 2021, 5:07pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/4 "2021-06-11T17:07:32Z")

</div>

> [@Kresimir](#):
>
> Here is a screenshot of my `neofetch` just for fun:

I dare say, for a “bloated kitch” hater, that’s a pretty fabulously riced neofetch you have there 😁

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [June 11, 2021, 6:02pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/5 "2021-06-11T18:02:56Z")

</div>

How about a slightly slower but more versatile way:

```auto
["$(date +%j)" != "$(cat ~/.nf 2>/dev/null)"] && neofetch > ~/.nf
cat ~/.nf

```

It updates the output about once a day.  
If more frequent is needed, then

```auto
["$(date +%H)" != "$(cat ~/.nf 2>/dev/null)"] && neofetch > ~/.nf
cat ~/.nf

```

updates about once every hour (if you start a terminal frequently enough).

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 6:14pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/6 "2021-06-11T18:14:53Z")

</div>

There is something wrong with that… The whole point of my post is to run `neofetch` in a separate non-interactive shell session (in the background), _after_ the terminal emulator was already opened and interactive shell session handled to the user (`setsid` is quite important here, alternatively you can just make a background process with `&`, but `setsid` is better). We don’t want the user to have to wait until `neofetch` has finished running to get control of the terminal emulator.

> [@manuel](#):
>
> ```auto
> ["$(date +%j)" != "$(cat ~/.nf 2>/dev/null)"]
> 
> ```

What does this test even do? It tests whether the output of the `date` command (the current day in the year) is different from the contents of the file holding the output of `neofetch`, but with newlines removed? That will always be true (as these two things are never equal). So you’re basically running `neofetch` every time the terminal is opened, saving the output to a file, and then printing that file. That seems entirely pointless to me.

I might be missing something here…

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [June 11, 2021, 6:28pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/7 "2021-06-11T18:28:21Z")

</div>

Yes, you’re right, sorry about that.

The purpose was to store the `date` output to another file (like ~/.nf.prevtime), but I wrote that too quickly and without testing.

This should work but maybe not fast enough?

```auto
["$(date +%j)" != "$(cat ~/.nf.prevtime 2>/dev/null)"] && { neofetch > ~/.nf; date +%j > ~/.nf.prevtime; cat ~/.nf; } || cat ~/.nf

```

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 6:31pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/8 "2021-06-11T18:31:49Z")

</div>

Oh, that makes more sense. But why complicate things this way? The first time in the day you run your terminal emulator, it will be slow. Every other time, it will be fast, but the `neofetch` output will be that of the first one in the day.

In that case, it’s better to generate the `neofetch` output file on every boot.

In my method, the terminal opens quickly every time, and the output of `neofetch` is generated every time the terminal is opened, meaning you get the output that was generated the last time you opened your terminal emulator (which is fresher, if you open your terminal more than once a day).

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [June 11, 2021, 6:36pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/9 "2021-06-11T18:36:41Z")

</div>

Your solution is better in many ways. I was just toying around.

One extremely minor thing though in your clever code: the _first_ time terminal is started (before .nf is created), it does not show neofetch output. 😉

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 6:37pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/10 "2021-06-11T18:37:36Z")

</div>

> [@manuel](#):
>
> One extremely minor thing though in your clever code: the _first_ time terminal is started (before .nf is created), it does not show neofetch output. 😉

This will only happen once in your life 🤣

Think of that singular occurrence as part of setting this thing up.

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [June 11, 2021, 6:38pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/11 "2021-06-11T18:38:04Z")

</div>

Very true! 🤣

---

<div class="post-metadata">

**Author:** ![manuel](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/manuel/32/396_2.png) [@manuel](https://forum.endeavouros.com/u/manuel)\
**Post date:** [June 11, 2021, 6:40pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/12 "2021-06-11T18:40:27Z")

</div>

I removed both from my .bashrc… 😂

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 6:40pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/13 "2021-06-11T18:40:36Z")

</div>

The only real downside to my method that I can think of is if you do not use the terminal often. If you open your terminal once every 6 months, you’ll always get a 6 month old `neofetch` output. In that case, you should generate the `.nf` file on every boot.

But if you open your terminal multiple times a day, it will be fairly fresh.

---

<div class="post-metadata">

**Author:** ![dbarronoss](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dbarronoss](https://forum.endeavouros.com/u/dbarronoss)\
**Post date:** [June 11, 2021, 7:12pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/14 "2021-06-11T19:12:09Z")

</div>

I’ve never been entirely sure why anyone would want this on each terminal. Good tip though.

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 7:13pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/15 "2021-06-11T19:13:58Z")

</div>

Because of rice, man. Aesthetics over usability 🙂

Yeah, I don’t get it either, but people like it, and who am I to say they are wrong? (Well, they are, but that’s beside the point, `nobody` is harmed)

---

<div class="post-metadata">

**Author:** ![dbarronoss](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dbarronoss](https://forum.endeavouros.com/u/dbarronoss)\
**Post date:** [June 11, 2021, 7:15pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/16 "2021-06-11T19:15:11Z")

</div>

And no electrons were discharged by the cpu power utilized over thousands of terminals ? 🙂  
My version of ‘and no kittens were killed to produce this ad.’

---

<div class="post-metadata">

**Author:** ![anon75994754](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@anon75994754](https://forum.endeavouros.com/u/anon75994754)\
**Post date:** [June 11, 2021, 7:17pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/17 "2021-06-11T19:17:02Z")

</div>

i guilty 😔 i have figlet , no have neofetch so no total insane 😊

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 7:17pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/18 "2021-06-11T19:17:26Z")

</div>

@dbarronoss relevant: [Post your handy utility scripts! - #121 by keybreak](https://forum.endeavouros.com/t/post-your-handy-utility-scripts/7213/121)

@anon75994754, I hope you saved that figlet output to a file (for example: `figlet Hello > .greeter`) and then just have `cat .greeter` in your `.bashrc` 🙂  
Otherwise Greta will come to you at night and haunt you in your dreams.

---

<div class="post-metadata">

**Author:** ![anon75994754](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/d78d45/32.png) [@anon75994754](https://forum.endeavouros.com/u/anon75994754)\
**Post date:** [June 11, 2021, 7:22pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/19 "2021-06-11T19:22:59Z")

</div>

i no do … 🙏 😊

---

<div class="post-metadata">

**Author:** ![Kresimir](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/kresimir/32/73739_2.png) [@Kresimir](https://forum.endeavouros.com/u/Kresimir)\
**Post date:** [June 11, 2021, 7:24pm UTC](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116/20 "2021-06-11T19:24:33Z")

</div>

Quicky now, there is little time left, Greta is on her way!

![frog_scream_72](https://forum.endeavouros.com/uploads/default/original/2X/1/102012fb423304860010dcd84485485bf28ff4cc.png)

[Next page](https://forum.endeavouros.com/t/tip-a-better-way-to-add-neofetch-to-your-bashrc/15116.md?page=2)
