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

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. :slight_smile:

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:


add this instead to your .bashrc:

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:


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.


That’s better :wink:

setsid bloatkitch >| .bk

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

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…

1 Like

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


How about a slightly slower but more versatile way:

[ "$(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

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

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

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.

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…

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?

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

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).

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. :wink:

1 Like

This will only happen once in your life :rofl:

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


Very true! :rofl:

I removed both from my .bashrc… :joy:

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.

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

1 Like

Because of rice, man. Aesthetics over usability :slight_smile:

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)

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

1 Like

i guilty :pensive: i have figlet , no have neofetch so no total insane :blush:


@dbarronoss relevant: Post your handy utility scripts! - #121 by keybreak

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

1 Like

i no do … :pray: :blush:

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