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